Scripting Blog [archived]

Formerly known as the "Hey, Scripting Guy!" blog

Latest posts

Feb 19, 2016
Post comments count 0
Post likes count 0

Migrate Windows CA from CSP to KSP and from SHA-1 to SHA-256: Part 5

Doctor Scripto

Summary: Thomas Rayner, Microsoft Cloud & Datacenter Management MVP, shows how to modify the registry for SHA-256 as a part of migrating a Windows certification authority from CSP to KSP and from SHA-1 to SHA-256. Hello! I’m Thomas Rayner, a proud Cloud & Datacenter Management Microsoft MVP, filling in for The Scripting Guy this week. You can find me on Twitter (@MrThomasRayner) or on my blog, Working Sysadmin: Figuring stuff out at work. I recently had the chance to work with Microsoft PFE, Mike MacGillivray, on an upgrade of some Windows certification authorities, and I want to share some information ...

Feb 18, 2016
Post comments count 0
Post likes count 0

PowerTip: Count backwards in array

Doctor Scripto

Summary: Cloud & Datacenter Management MVP, Thomas Rayner, shows how to count backwards in a Windows PowerShell array.  I know I can access the first, second, and third items in an array by using $Array[0], $Array[1], and $Array[2], but how can I count backwards?  Use negative numbers, for example: $Array = @('first','second','third') $Array[0] $Array[1] $Array[2] $Array[-1] $Array[-2] $Array[-3] This will output the following: first second third third second first

Feb 18, 2016
Post comments count 0
Post likes count 0

Migrate Windows CA from CSP to KSP and from SHA-1 to SHA-256: Part 4

Doctor Scripto

Summary: Thomas Rayner, Microsoft Cloud & Datacenter Management MVP, shows how to import a certificate into a KSP and bring it into the certificate store. Hello! I’m Thomas Rayner, a proud Cloud & Datacenter Management Microsoft MVP, filling in for The Scripting Guy this week. You can find me on Twitter (@MrThomasRayner) or on my blog, Working Sysadmin: Figuring stuff out at work. I recently had the chance to work with Microsoft PFE, Mike MacGillivray, on an upgrade of some Windows certification authorities, and I want to share some information about it with you. This script has only been tested on Wind...

Feb 17, 2016
Post comments count 0
Post likes count 0

PowerTip: Prompt user for value but provide default

Doctor Scripto

Summary: Cloud & Datacenter Management MVP, Thomas Rayner, shows how to set a variable to a default value in PowerShell.  How can I use Windows PowerShell to prompt a user for a value for a variable, but provide a default value if the user doesn’t enter anything?  First prompt the user for the value to the variable and then detect if the response was empty. If the response is empty, set the value of the variable. You can validate parameters for a function more conveniently than this. This code is for inline variables in an interactive script: $Interesting = Read-Host -Prompt 'Give me a value [some-value]' if...

Feb 17, 2016
Post comments count 0
Post likes count 0

Migrate Windows CA from CSP to KSP and from SHA-1 to SHA-256: Part 3

Doctor Scripto

Summary: Thomas Rayner, Microsoft Cloud & Datacenter Management MVP, shows how to delete your Windows CA certificates and crypto provider as a part of migrating a Windows certification authority from CSP to KSP and from SHA-1 to SHA-256. Hello! I’m Thomas Rayner, a proud Cloud & Datacenter Management Microsoft MVP, filling in for The Scripting Guy this week. You can find me on Twitter (@MrThomasRayner) or on my blog, Working Sysadmin: Figuring stuff out at work. I recently had the chance to work with Microsoft PFE, Mike MacGillivray, on an upgrade of some Windows certification authorities, and I want to...

Feb 16, 2016
Post comments count 0
Post likes count 0

PowerTip: Use positional parameters

Doctor Scripto

Summary: Cloud & Datacenter Management MVP, Thomas Rayner, shows how to use positional parameters in Windows PowerShell.  I always see people pass variables or data to a function without specifying the parameter name that the data is for, for example: “copy-item $source $destination” acts like “copy-item –path $source –destination $destination” How do I do that in my functions, and how does the function know which variable is the path and destination?  In functions, you declare parameters before doing much else. When declaring your parameter, indicate the Position starting with 0, for example: Function Invok...

Feb 16, 2016
Post comments count 0
Post likes count 0

Migrate Windows CA from CSP to KSP and from SHA-1 to SHA-256: Part 2

Doctor Scripto

Summary: Thomas Rayner, Microsoft Cloud & Datacenter Management MVP, shows how to back up your Windows certification authority as a part of migrating from CSP to KSP and from SHA-1 to SHA-256. Hello! I’m Thomas Rayner, a proud Cloud & Datacenter Management Microsoft MVP, filling in for The Scripting Guy this week. You can find me on Twitter (@MrThomasRayner) or on my blog, Working Sysadmin: Figuring stuff out at work. I recently had the chance to work with Microsoft PFE, Mike MacGillivray, on an upgrade of some Windows certification authorities, and I want to share some information about it with you. Th...

Feb 15, 2016
Post comments count 0
Post likes count 0

PowerTip: Send output to file and screen at the same time

Doctor Scripto

Summary: Cloud & Datacenter Management MVP, Thomas Rayner, shows how to easily send data to the output of a script.  How can I use Windows PowerShell to send the same data that I’m writing to a file to the standard output of my script?  In Windows PowerShell 5.0, use Tee-Object, for example: PS C:\WINDOWS\system32> Tee-Object -InputObject 'Some text' -FilePath 'C:\temp\some file.txt' Some text PS C:\WINDOWS\system32> Get-Content -Path 'C:\temp\some file.txt' Some text

Feb 15, 2016
Post comments count 1
Post likes count 0

Migrate Windows CA from CSP to KSP and from SHA-1 to SHA-256: Part 1

Doctor Scripto

Summary: Thomas Rayner, Microsoft Cloud & Datacenter Management MVP, shows how to start the migration of a Windows certification authority from CSP to KSP and from SHA-1 to SHA-256. Hello! I’m Thomas Rayner, a proud Cloud & Datacenter Management Microsoft MVP, filling in for The Scripting Guy this week. You can find me on Twitter (@MrThomasRayner) or on my blog, Working Sysadmin: Figuring stuff out at work. I recently had the chance to work with Microsoft PFE, Mike MacGillivray, on an upgrade of some Windows certification authorities, and I want to share some information about it with you. This script h...