Scripting Blog [archived]

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

Latest posts

All good things must come to an end
Feb 16, 2021
Post comments count 4
Post likes count 18

All good things must come to an end

Doctor Scripto
Doctor Scripto

Introduction of New PowerShell Community Blog and Retirement of "Hey Scripting Guy!" Blog, the passing of the Torch to a new Generation.

Testing RPC ports with PowerShell (and yes, it’s as much fun as it sounds!) New and Improved!!
Jan 31, 2021
Post comments count 2
Post likes count 0

Testing RPC ports with PowerShell (and yes, it’s as much fun as it sounds!) New and Improved!!

Doctor Scripto
Doctor Scripto

Summary: Using PowerShell to identify RPC ports in use by capturing content from PowerShell We'd like to introduce you today to one of our newest bloggers!  It's a froopingly awesome friend of ours, Joel Vickery, PFE.  (did I mention Dr. Scripto is a big fan of books written by Douglas Adams?....oops!) Take it away Joel! Thanks Doc!  So hey everybody! What do you do when you have to troubleshoot the dreaded "RPC Unavailable" error 1722, which rears its ugly head anywhere from Active Directory replication to Configuration Manager Distribution Point installations, and many other places in between? We have the ans...

Import Azure DevOps Test Plans from One Environment to Another
Sep 9, 2020
Post comments count 0
Post likes count 2

Import Azure DevOps Test Plans from One Environment to Another

Claudia Ferguson
Claudia Ferguson

Summary Standardization of Azure DevOps Test Plans and Reusing Them Between Different Organizations Today we introduce Claudia Ferguson and Mike Stiers to the Scripting Blog. Claudia is a Senior Consultant with the Microsoft Active Directory Migration Services Engineer team, and Mike Stiers is a Microsoft Consultant from Toronto Canada. His focus is to help teams to use scalable infrastructure as code deployments in Azure DevOps. They put together something you will find to be very useful when you need to move DevOps test plans. There is some PowerShell here too (as it's the Scripting Blog!) but the content is...

Just go with the flow…. WorkFlow that is with Windows PowerShell
Dec 18, 2019
Post comments count 6
Post likes count 0

Just go with the flow…. WorkFlow that is with Windows PowerShell

Doctor Scripto
Doctor Scripto

Doctor Scripto returns again with our good friend Joel Vickery, PFE who is going to touch on the use of Workflows In PowerShell. Take it away Joel! Following up on my original post Parallel Processing with jobs in PowerShell, I wanted to go into another method of running parallel processes in PowerShell, namely WorkFlows. WorkFlow is very similar to using the Start-Job/-asJob functionality but it has some distinct advantages that are fully covered in many other blog postings on TechNet.  I'll mention them quickly below, but if you want deeper detail, see the When Windows PowerShell Met WorkFlow blog posting...

PowerTip: Identify Completed PowerShell Jobs with Data yet to be Received
Dec 11, 2019
Post comments count 0
Post likes count 0

PowerTip: Identify Completed PowerShell Jobs with Data yet to be Received

Doctor Scripto
Doctor Scripto

Summary: Doctor Scripto quickly shows how to identify Completed Jobs in PowerShell which have yet to have the data Received Hey Doctor Scripto, How can I identify jobs which already completed but I haven’t done a Receive-Job on to get the data? You can do this with the Get-Job Cmdlet by targeting the -ChildJobState and -HasMoreData like the following example Get-Job -ChildJobState Completed -HasMoreData:$True PowerShell, Doctor Scripto, PowerTip, Sean Kearney

Parallel Processing with jobs in PowerShell
Dec 11, 2019
Post comments count 3
Post likes count 0

Parallel Processing with jobs in PowerShell

Doctor Scripto
Doctor Scripto

Joel Vickery discusses an introductory use of PowerShell jobs and working with data

PowerTip: Use Windows PowerShell to display all Environment variables
Nov 13, 2019
Post comments count 3
Post likes count 2

PowerTip: Use Windows PowerShell to display all Environment variables

Doctor Scripto
Doctor Scripto

Summary: Doctor Scripto demonstrates how to use env: to show all currently set environment variables Question: Hey Doctor Scripto, I remember in DOS if I wanted to see the values of all the Environment variables; like TEMP I could just type the SET Command. How do I do this in PowerShell? Answer: You can do this in one line using the env: PowerShell drive to display all of the currently set Environment variables. dir env: PowerShell, Doctor Scripto, PowerTip, Sean Kearney  

PowerTip: Identify if CredentialGuard is enabled with Windows PowerShell
Oct 30, 2019
Post comments count 3
Post likes count 0

PowerTip: Identify if CredentialGuard is enabled with Windows PowerShell

Doctor Scripto
Doctor Scripto

Summary: Easily identify if Credential Guard is enabled using the Get-ComputerInfo Cmdlet in Windows 10 Question: Hey Doctor Scripto, how can I tell if CredentialGuard has been enabled on my Windows 10 computer? Answer: Just use the Get-ComputerInfo Cmdlet and target the DeviceGaurdSecurityServicesConfigured property. The following line will produce a Boolean $TRUE if it is enabled. 'CredentialGuard' -match ((Get-ComputerInfo).DeviceGuardSecurityServicesConfigured) PowerShell, Doctor Scripto, PowerTip, Credential Guard, Paul Greeley  

Use PowerShell to Identify Unassociated Azure Resources
Oct 30, 2019
Post comments count 2
Post likes count 0

Use PowerShell to Identify Unassociated Azure Resources

Doctor Scripto
Doctor Scripto

Summary: Save costs by Identifying Unassociated Resources left behind after deletions in Azure Q: Hey, Scripting Guy! How can I quickly identify un-associated resources in my Azure subscription? A: Hi SH! At least you know that’s a question to ask! I myself when I first began exploring this new world didn’t realize that when deleting a virtual system in Azure, not all the associated resources are deleted with it! First things first, if you’ve never done it, you’ll need to install the Azure PowerShell modules. This can be done by following the steps provided here on docs.microsoft.com Install the...

PowerTip: Using Set-ADUser with multi-valued attributes
Oct 23, 2019
Post comments count 1
Post likes count 1

PowerTip: Using Set-ADUser with multi-valued attributes

Doctor Scripto
Doctor Scripto

Summary: Using the -Replace parameter with Set-ADUser to take an array to populate multi-valued attributes Question: Hey Doctor Scripto, how can I use Set-ADUser to populate multivalued attributes in Active Directory? Answer: You can use an array with the -Replace parameter to do it. Set-ADUser -Identity "TestUser" -Replace @{ProxyAddresses = @("Address1","Address2","Address3")} PowerShell, Doctor Scripto, PowerTip, Active Directory, Walid Moselhy  

Copy multi-valued Active Directory attributes from one user to another with PowerShell
Oct 23, 2019
Post comments count 1
Post likes count 0

Copy multi-valued Active Directory attributes from one user to another with PowerShell

Doctor Scripto
Doctor Scripto

Summary: Using -Replace parameter with Set-ADUser to copy Active Directory multi-valued attributes Q: Hey, Doctor Scripto! We are in the middle of an Active Directory migration and need to copy the multi-valued attribute “ProxyAddresses” from old user accounts to new ones. Can you do with a few lines of code? —ND A: Hello ND, Hello everyone, your good friend Doctor Scripto is here with Walid, one of our PFEs who really likes mixing PowerShell with Active Directory. Walid, what do you think of this one? Well, Doctor Scripto, it makes a lot of sense to try and automate this type of tasks. Who like...

PowerTip: Use New-Alias to make Cmdlets easier to remember
Oct 16, 2019
Post comments count 0
Post likes count 0

PowerTip: Use New-Alias to make Cmdlets easier to remember

Doctor Scripto
Doctor Scripto

Using New-Alias to create easier to remember shortcuts in PowerShell

Using PowerShell to View and Remove Wireless Profiles in Windows 10 – Part 4
Oct 16, 2019
Post comments count 0
Post likes count 0

Using PowerShell to View and Remove Wireless Profiles in Windows 10 – Part 4

Doctor Scripto
Doctor Scripto

Summary: Using Windows PowerShell to purge Wlan profiles with NetSh.exe. Last week we had a way with a Regular Expression to run one Netsh.exe command and show only the profile names as a PowerShell Array. Today we're going to finish the task and show you how to delete those Profiles. As a quick reminder here's the line in PowerShell we used to capture the list of Wireless profiles by only their names as an Array. The resulting output containing our Wireless profile names looked like this From our first posting we saw that to delete a WLAN profile in Netsh.exe we would execute this command. ...

PowerTip: Show all Installed Capabilities on Windows 10
Oct 9, 2019
Post comments count 0
Post likes count 0

PowerTip: Show all Installed Capabilities on Windows 10

Doctor Scripto
Doctor Scripto

Summary: Identify if capabilities like OpenSSH are installed in your Windows 10 Operating System Hey, Doctor Scripto. I was curious if there was a way to see if a workstation has a capability installed on it like OpenSSH. I’m trying to report on this for my environment. Absolutely! You can run the following line on a workstation to show the installed Capabilities like OpenSSH Get-WindowsCapability -Online | Where-Object { $_.State -eq 'Installed' } PowerShell, Doctor Scripto, PowerTip, Sean Kearney

Using PowerShell to View and Remove Wireless Profiles in Windows 10 – Part 3
Oct 9, 2019
Post comments count 0
Post likes count 0

Using PowerShell to View and Remove Wireless Profiles in Windows 10 – Part 3

Doctor Scripto
Doctor Scripto

Summary: Using Regular Expressions to cleanup string data from NetSh.exe. Let's remember the last two discussions. The first time we looked at using PowerShell to identify wireless profiles with some simple regular expressions. We followed up the next week with how to identify which approach would be the fastest. Today we're going to take that array of information and clean it up so we only have the profile names. As a quick reminder here's the line in PowerShell we used to capture the list of Wireless profiles The resulting output looked like this What we need to do now is cleanup this data so...

PowerTip: Identify Drives Encrypted with Bitlocker
Oct 2, 2019
Post comments count 0
Post likes count 0

PowerTip: Identify Drives Encrypted with Bitlocker

Doctor Scripto
Doctor Scripto

Summary: Using the Get-Bitlocker Cmdlet to show the status of drives on your Windows 10 computer Hey, Doctor Scripto. Is there a nice simple way to see if drives are Bitlocker encrypted? A most excellent question! You can the Get-BitlockerVolume Cmdlet and filter on the VolumeStatus property. Here's an example of a line that will show only drives which have Bitlocker enabled. Get-BitLockerVolume | Where-Object { $_.VolumeStatus -eq 'FullyEncrypted' } PowerShell, Doctor Scripto, PowerTip, Sean Kearney  

Using PowerShell to View and Remove Wireless Profiles in Windows 10 – Part 2
Oct 2, 2019
Post comments count 2
Post likes count 0

Using PowerShell to View and Remove Wireless Profiles in Windows 10 – Part 2

Doctor Scripto
Doctor Scripto

Summary: Using Measure-Command to determine the fastest approach to a solution. Last week we were having some fun using PowerShell as a wrapper around the NetSh.exe command's output. We were left at a decision point. Which way to go? A For loop to clean up the data, which worked fine or Regular Expressions. Although both work which was the better path to use? For me initially, when I first started in PowerShell I very often used a For loop for a few reasons. But as I progressed in my knowledge of PowerShell I've started to touch on Regular expressions as a solution when possible. A go...

PowerTip: Converting a Here-String to an Array in One Line with PowerShell
Sep 25, 2019
Post comments count 2
Post likes count 0

PowerTip: Converting a Here-String to an Array in One Line with PowerShell

Doctor Scripto
Doctor Scripto

Summary: Using the split method in a more powerful fashion to split an array based upon two line terminating types Hey, Doctor Scripto. I was wondering if there was a more efficient way of converting a Here-String to an Array when there were multiple line termination options like Linefeed or Carriage Return and Linefeed? There most definitely is. You can pass multiple parameters to the split method. This example traps both! $HereStringSample=@' Banana Raspberry '@ $HereStringSample.Split(@("$([char][byte]10)", "$([char][byte]10)","$([char][byte]13)", [StringSplitOptions]::None)) PowerShe...

Using PowerShell to View and Remove Wireless Profiles in Windows 10 – Part 1
Sep 25, 2019
Post comments count 0
Post likes count 0

Using PowerShell to View and Remove Wireless Profiles in Windows 10 – Part 1

Doctor Scripto
Doctor Scripto

Summary: Using PowerShell and Regular Expressions as a wrapper on NetSh.exe output to identify the profiles. Hey, Doctor Scripto! I have a whole pile of old Wireless profiles that have been collecting dust. I know I can use NETSH to view and delete them, but the process is very manual. Do you know if there is an easier way to clear them up? —WF Hello WF, you asked I shall help. Doctor Scripto is in the house! I know the process you mean, I had to do this a few years ago on one of my old laptops. I had wireless profiles from my home, hotels, offices, coffee shops. It was just silly. I think there we...

PowerTip: Identify which Platform PowerShell is running on
Sep 18, 2019
Post comments count 1
Post likes count 0

PowerTip: Identify which Platform PowerShell is running on

Doctor Scripto
Doctor Scripto

Summary: Using $PSVersionTable to identify if you are on Windows or Unix Hey, Doctor Scripto! I'm working on my PowerShell scripts and I need to be able to identify if I'm working on Windows or Linux. How can I do this easily? No problem at all and glad to help. Just examine the $PSVersionTable property called Platform. It will contain one either 'Unix','Win32NT' on PowerShell Core. In the case of Windows PowerShell it will not exist. $PSVersionTable.Platform PowerShell, Doctor Scripto, PowerTip, Sean Kearney  

Creating a Platform Independent Function in PowerShell
Sep 18, 2019
Post comments count 1
Post likes count 0

Creating a Platform Independent Function in PowerShell

Doctor Scripto
Doctor Scripto

Summary: Creating a Function in PowerShell and the power of the $PSVersionTable to make code more portable Q: Hey, Doctor Scripto! I saw that post last week on converting Here-String into an array. I wanted to write my code to trap for PowerShell and PowerShell Core. Could you give me a helping hand? —PG A: Hello PG, Hello everyone, your good friend Doctor Scripto is here with Sean sitting across from me having lunch. Sean what do you think about this idea? Well Doctor Scripto this is actually pretty easy and it makes a LOT of sense to have a function do this to avoid re-writing the same code. ...

PowerTip: Identify if you are running on PowerShell Core
Sep 11, 2019
Post comments count 0
Post likes count 0

PowerTip: Identify if you are running on PowerShell Core

Doctor Scripto
Doctor Scripto

Summary: Pulling up the properties of $PSVersionTable to identify your PowerShell edition Hey, Doctor Scripto! I want to write my modules and scripts to be more portable. How can I tell if I am executing on PowerShell Core? Just use the $PSVersionTable object and examine the PSEdition value. If it returns 'Core' you are running on PowerShell core. $PSVersionTable.PSEdition PowerShell, Doctor Scripto, PowerTip, Sean Kearney  

Maximizing the Power of Here-String in PowerShell for Configuration Data
Sep 11, 2019
Post comments count 3
Post likes count 0

Maximizing the Power of Here-String in PowerShell for Configuration Data

Doctor Scripto
Doctor Scripto

Summary: Discovering some of the awesome and neat ways to leverage a Here-String in a Script or function Q: Hey, Doctor Scripto! I used to write scripts with supporting configuration files that never really changed. I was wondering if there was any way to put them INSIDE the script directly to make it self contained. —AB A: Hello AB, I was chatting with my good friend Sean on this one. Here he talks about using Here-Strings to solve this problem. Thanks Doctor Scripto, yes a Here-String can be a great way to embed the configuration or other data for that matter in a script. If you've never encou...

PowerTip: Read a JSON configuration file as a PowerShell object
Sep 4, 2019
Post comments count 0
Post likes count 1

PowerTip: Read a JSON configuration file as a PowerShell object

Doctor Scripto
Doctor Scripto

Summary: Using the ConvertFrom-Json Cmdlet in PowerShell to read a JSON formatted file Hey, Doctor Scripto! I've seen a lot of JSON files in use in Azure. I'm not very good with editing JSON properly. Is there an easy way to read this and at least edit it with PowerShell? Most definitely my good friend. For the file below called "settings.json" you can convert it to a PowerShell Object for editing purposes using the following line.   Once you have completed this, you can manipulate it like any other PowerShell Object. $PowerShellObject=Get-Content -Path settings.json | ConvertFrom-Json Pow...

Configuring Startup Settings in Microsoft Teams with Windows PowerShell
Sep 4, 2019
Post comments count 2
Post likes count 0

Configuring Startup Settings in Microsoft Teams with Windows PowerShell

Doctor Scripto
Doctor Scripto

Summary: Using the ConvertFrom-JSON and ConvertTo-JSON Cmdlets to edit a configuration file Q: Hey, Doctor Scripto! I need to be able to change the Startup settings in Teams (like the Auto launch feature). I can change it in the Interface, but I need to be able to edit across multiple systems. Could you lend me a hand? —RL A: Hello RL, A very excellent question. For which it produced a most interesting solution when I asked Sean Kearney one of our Microsoft PFE's to look at it. Take it away Sean! Let's begin by examining the settings we are trying to change. They can be accessed under the "Setti...

PowerTip: Using PowerShell to Convert raw Text to a Comma Separated columm
Aug 28, 2019
Post comments count 0
Post likes count 0

PowerTip: Using PowerShell to Convert raw Text to a Comma Separated columm

Doctor Scripto
Doctor Scripto

Summary: Using PowerShell and a very simple Regular Expression to convert Random counts of spaces to a Comma Hey Doctor Scripto! I have some string based output from a non PowerShell application. The output is good but I need to easily parse it. Is there a way to convert that data to something consistent like "Comma Separated?" Why yes you can! This is something that is easily done with a regular expression. Using a simple example like this will identify all content with more than one blank space separating it, and replace it with a comma! $SampleText='Hello             This                      ...

Automating Quser through PowerShell
Aug 27, 2019
Post comments count 0
Post likes count 0

Automating Quser through PowerShell

Doctor Scripto
Doctor Scripto

Summary: Using PowerShell to automate Quser to identify users to Logoff systems in Windows Hey Doctor Scripto! I need to log a user off every computer they’re logged into. The problem is, I don’t know which ones. How can I discover which computers they’re logged into and then log them off? That's a most excellent question!  I know just the person who can answer that.   I was talking my good friend Dan Reist on this topic.   Dan is a Senior Consultant on Data Platforms here at Microsoft.   He actually ran into that same issue. Dan, the room is yours today, take it away! Thanks Doctor Scripto! So my ...

PowerTip: Identify if SQL Servers are configured to best practices
Aug 21, 2019
Post comments count 0
Post likes count 0

PowerTip: Identify if SQL Servers are configured to best practices

Doctor Scripto
Doctor Scripto

Summary: Using the features of the SQLServer PowerShell module to run assessments of your servers How can I easily check that my SQL Servers are all configured to meet best practices? You can use SQL Server Assessments – the latest addition to the SQLServer PowerShell module. Just Run a best practices assessment on your SQL Server as seen below Get-SqlInstance  "DemoSQLServer" | Invoke-SqlAssessment PowerShell, Doctor Scripto, PowerTip, Johnathan Allen, SQL Server  

Executing SQL Server Assessments from PowerShell
Aug 21, 2019
Post comments count 0
Post likes count 0

Executing SQL Server Assessments from PowerShell

Doctor Scripto
Doctor Scripto

Summary: Using the SQLServer module cmdlets to review and monitor SQL Server instance and database configuration Q: Hey, Doctor Scripto! I have loads of SQL Servers in my area of responsibility and I know they all need certain configuration settings but I'm never confident that they are all set just right so I spend a long time every month visiting them all over RDP to give reassure myself. How can I automate this work? —AB A: Hello AB, I know the very person that can answer that question for you. It's my good friend Jonathan Allen. Let me introduce him to you. He's a SQL Server PFE from the UK. He...

PowerTip: Identify Synchronized AzureAD accounts without a License assigned
Aug 14, 2019
Post comments count 4
Post likes count 0

PowerTip: Identify Synchronized AzureAD accounts without a License assigned

Doctor Scripto
Doctor Scripto

Summary: Using PowerShell to identify users who are Synchronized to AzureAD but not yet licensed Hey, Doctor Scripto! I'd love to be able to identify users Synchronized to AzureAD that haven't yet had their licenses assigned.   Help a friend out? No problem at all!  You can target that information with two parameters in the Get-Msoluser Cmdlet! Get-MsolUser -UnlicensedUsersOnly -Synchronized PowerShell, Doctor Scripto, PowerTip, AzureAD  

Reporting on Microsoft 365 Licensing using PowerShell – Part 3
Aug 14, 2019
Post comments count 1
Post likes count 0

Reporting on Microsoft 365 Licensing using PowerShell – Part 3

Doctor Scripto
Doctor Scripto

Summary: Will Martin finalizes his discussion on how to report on Microsoft 365 licensing in the cloud. Previous Posts on this article can be found here for continuity Reporting on Microsoft 365 Licensing using PowerShell – Part 1 Reporting on Microsoft 365 Licensing using PowerShell – Part 2 Dr. Scripto here! When last we saw Will Martin, he was deep in a script pulling down licensing tables and produced a lovely hash table. Let’s watch for the exciting conclusion! From last week, we placed our data in a hash table. Now, let’s swap it from a hash table to CSV format by changing our last active lin...

PowerTip: Identify the last time Users changed passwords in AzureAD
Aug 7, 2019
Post comments count 0
Post likes count 0

PowerTip: Identify the last time Users changed passwords in AzureAD

Doctor Scripto
Doctor Scripto

Summary: Using PowerShell to report on Users and the last time Passwords were changed Hey, Doctor Scripto! I need to report on users and when they updated their passwords In AzureAD. Could you show me how ? Most certainly, I love to provide a helping hand however I can. Using the Get-Msoluser Cmdlet just target the LastPasswordChangeTimeStamp Attribute. Here's an example of it in use. Get-MsolUser | Select-Object DisplayName, UserPrincipalName, LastPasswordChangeTimeStamp PowerShell, Doctor Scripto, PowerTip, AzureAD  

Reporting on Microsoft 365 Licensing using PowerShell – Part 2
Aug 7, 2019
Post comments count 0
Post likes count 0

Reporting on Microsoft 365 Licensing using PowerShell – Part 2

Doctor Scripto
Doctor Scripto

Summary: Will Martin continues his discussion on how to report on Microsoft 365 licensing in the cloud. Previous Posts on this article can be found here for continuity Reporting on Microsoft 365 Licensing using PowerShell – Part 1 Remember from last week we showed the results of what a user licensed in Microsoft 365 looked like in the web portal? So, what does this look like if we try to access it in PowerShell? Well, we have the user, and the service plan. Can we get this into a usable format? Well, let’s see what we can do – let’s try pulling this info for our last three users and see what we...

PowerTip: Identify the last time a User was Synchronized to AzureAD
Jul 31, 2019
Post comments count 0
Post likes count 0

PowerTip: Identify the last time a User was Synchronized to AzureAD

Doctor Scripto
Doctor Scripto

Summary: Use PowerShell to identify the property in AzureAD with the Synchronization time in AzureAD Hey, Doctor Scripto. Is there a way with PowerShell to identify when a user was last synchronized with AzureAD? Absolutely! We just need to examine the LastDirSyncTime when using the Get-Msoluser cmdlet. Here’s an example below (Get-MsolUser -UserPrincipalName 'drscripto@contoso.com').LastDirSyncTime PowerShell, Doctor Scripto, PowerTip, Microsoft 365    

Reporting on Microsoft 365 Licensing using PowerShell – Part 1
Jul 31, 2019
Post comments count 0
Post likes count 0

Reporting on Microsoft 365 Licensing using PowerShell – Part 1

Doctor Scripto
Doctor Scripto

Summary: Will Martin discusses how to report on Microsoft 365 licensing in the cloud. Hello everyone, Doctor Scripto here today to introduce you to a good friend of mine. Will Martin is a PFE in Messaging here at Microsoft and he wanted to share a wonderful solution he found on reporting on Microsoft 365 licensing with PowerShell. Will my friend, the Blog is now in your most capable hands! Thanks for the introduction Doctor Scripto! I came across an interesting problem recently. I was asked by my large Office 365 customer if I could give them a script that would output all their user account licensing...

PowerTip: Show files with expired Digital Certificates
Jul 24, 2019
Post comments count 0
Post likes count 0

PowerTip: Show files with expired Digital Certificates

Doctor Scripto
Doctor Scripto

Summary: Targeting Expired Certificates with Get-AuthenticodeSignature Question: Hey Doctor Scripto! Is there an easy way to visually identify Digitally signed files with an Expired status on the Digital Certificate? Answer: Absolutely! We just need to filter on the “Status” property and show those without the value ‘Valid’. As an added bonus it would also identify files that are not digitally signed. Get-Childitem C:\Folder\*.* -Recurse | Get-AuthenticodeSignature | Where-Object { $_.Status -ne 'Valid' } PowerShell, Doctor Scripto, PowerTip  

Reporting on Digitally Signed Files with PowerShell
Jul 24, 2019
Post comments count 1
Post likes count 0

Reporting on Digitally Signed Files with PowerShell

Doctor Scripto
Doctor Scripto

Summary: Using the Get-AuthenticodeSignature cmdlet to show if a file is Digitally Signed Q: Hey, Doctor Scripto! I was curious, since many new files are Digitally signed with a certificate if there was an easy way to see the status of the Digital Signatures of many files easily? —SH A: Hello SH your good friend Doctor Scripto is here today to help you along. One of the things which changed with PowerShell in version 3.0 was a beautiful little Cmdlet called Get-AuthenticodeSignature This Cmdlets task was very simple, examine a file and show the properties of the Digital Certificate on a file. He...

Clean up Domain Controller DNS Records with Powershell
Jul 17, 2019
Post comments count 1
Post likes count 3

Clean up Domain Controller DNS Records with Powershell

Doctor Scripto
Doctor Scripto

Summary: Using Windows PowerShell to remove Stale / Dead Domain Controller records. Q: Hey, Doctor Scripto! How can I quickly clean up all my dead Domain Controller’s DNS records? A: That’s a great question. The good Doctor also knows the very person to answer it best. My good friend Patrick Mercier, An Active Directory PFE who loves working with PowerShell. Take it away Patrick! Whether it’s as part of Active Directory Disaster Recovery, or because you had an old Domain Controller you needed to get rid of, cleaning up all the DNS records of a now dead DC left behind can be tedious: that is, unl...

PowerShell PowerTip: Customizing your prompt
Nov 13, 2018
Post comments count 0
Post likes count 1

PowerShell PowerTip: Customizing your prompt

Kory Thacher
Kory Thacher

I've been taking a break from the blog for a while due to some personal reasons, but I had a few people ask me about my PowerShell prompt recently. I like extra horizontal space, so I removed the path from the prompt and put it in the window title bar. I also just display the current time in the prompt itself. You can customize your prompt by using your profile and overriding the "Prompt" function. A coworker of mine, Tony Radkiewicz, used a similar prompt and I really liked it so I've been using it since. That's all for now, I'll try to get some...

PowerTip: Use PowerShell to pick a random name from a list
Sep 15, 2018
Post comments count 2
Post likes count 0

PowerTip: Use PowerShell to pick a random name from a list

Doctor Scripto
Doctor Scripto

Using the Get-Random Cmdlet to select a random list of names instead of numbers

Using PowerShell to create a folder of Demo data
Sep 15, 2018
Post comments count 2
Post likes count 2

Using PowerShell to create a folder of Demo data

Doctor Scripto
Doctor Scripto

Creating sample files with random sizes and dates for use in a Lab

PowerShell PowerTip: searching and installing modules on the command line
Aug 21, 2018
Post comments count 0
Post likes count 1

PowerShell PowerTip: searching and installing modules on the command line

Kory Thacher
Kory Thacher

PowerShell 5+ ships with the module PowerShellGet, which lets us search and install modules from cmdlets. The default nuget repository is the PowerShell Gallery, but you could add others yourself (including custom ones for internal modules). There are a lot of reasons this could help you: There are a lot of cmdlets in the module, but the ones you'll use the most will be: You can also specify the scope on install-module and put it in your user module location for ones just for you on a machine. Hope that helps, tune in more often to get short and sweet PowerTips!

Regular Expressions (REGEX): Grouping & [RegEx]
Aug 14, 2018
Post comments count 1
Post likes count 2

Regular Expressions (REGEX): Grouping & [RegEx]

Kory Thacher
Kory Thacher

Welcome back to the RegEx crash course. Last time we talked about the basic symbols we plan to use as our foundation. This week, we will be learning a new way to leverage our patterns for data extraction and how to rip our extracted data into pieces we care about. [RegEx] The  data type has some cool static members,  but we're mostly going to play with the plural method  if you don't know what static members are you can check this post or this help data. A lot of the time, when we work with RegEx we are using it to extract everything that matches our pattern in a large amount of data. Using  like we did in t...

PowerShell PowerTip: History of commands with PSReadline
Aug 7, 2018
Post comments count 0
Post likes count 0

PowerShell PowerTip: History of commands with PSReadline

Kory Thacher
Kory Thacher

One of the really cool things PSReadline provides (module shipping on v5+) isn't as immediately obvious as the syntax highlighting. It offers a persistent history that is stored from session to session. This means if you run commands in a window, close it, and open a new one later you can still hit the up arrow and scroll through them. I use this feature quite a bit doing demos or just working on things where I want to clear out my whole scope and jump back in. If you want to opt out you can as well: Hope that helps, tune in more often to get short and sweet PowerTips!

Regular Expressions (REGEX): Basic symbols
Jul 31, 2018
Post comments count 0
Post likes count 2

Regular Expressions (REGEX): Basic symbols

Kory Thacher
Kory Thacher

Welcome back to the RegEx guide. Last post we talked a little bit about the basics of RegEx and its uses. I mentioned the most important thing is to understand the symbols. Today we'll ease in with some of the basics to get us going, but later we will expand on these and see some other options we have.  is used to represent any single character, aside from a newline, so it will feel very similar to the windows wildcard  is the escape character for RegEx, the escape character has two jobs: We can use  to specify quantity in a few different ways by attaching them to characters or symbols. ...

PowerShell PowerTip: What is the point of Out-Variable?
Jul 24, 2018
Post comments count 0
Post likes count 2

PowerShell PowerTip: What is the point of Out-Variable?

Kory Thacher
Kory Thacher

A lot of times people see others using the common parameter -OutVariable instead of the best practice $var = <value>. This leads to a lot of folks wondering why OutVariable  exists. The real use for OutVariable is to save your data off, while still letting it get sent along the output stream. What this means is that you could use it somewhere inside of a pipe to save some data for later re-use, but continue doing other work with that data. Notice that even though the data continued being pipped along, I could also reference it later when I asked for the count. Hope that helps, tune in more ...

PowerTip: Turn off the power to your computer with PowerShell
Jul 16, 2018
Post comments count 1
Post likes count 0

PowerTip: Turn off the power to your computer with PowerShell

Doctor Scripto
Doctor Scripto

I’ve got a script that needs to power off a system after it’s done. How can I accomplish this with PowerShell?

Parse HTML and pass to Cognitive Services Text-to-Speech
Jul 16, 2018
Post comments count 0
Post likes count 0

Parse HTML and pass to Cognitive Services Text-to-Speech

Doctor Scripto
Doctor Scripto

Having some fun with Abbott and Costello’s “Who’s on first?” comedy routine, and multiple voices with Bing Speech.

PowerShell PowerTip: What you should know about streams
Jul 10, 2018
Post comments count 0
Post likes count 0

PowerShell PowerTip: What you should know about streams

Kory Thacher
Kory Thacher

PowerShell has a concept called Streams, which are the different places data can go (output, error, verbose, etc). You usually don't have to worry too much about these streams if you're just writing simple scripts, but it helps a ton to know: What this means for you, as users, is that you can get a non-terminating error, and still do work on the successful output. Take a look at this: Notice that even though I received an error for the process "FAKE", only the non-errors were present in $procs. Using some basic error handling we could clean that up, hide the error message and log out wha...

Regular Expressions (REGEX): Introduction
Jul 5, 2018
Post comments count 0
Post likes count 0

Regular Expressions (REGEX): Introduction

Kory Thacher
Kory Thacher

Hi all, this week I'll be talking about Regular Expressions. I've got a few posts planned to get you set up and going with some basic Regex. Regex is used for extracting and validating data. Essentially, you can think of Regex as windows wild cards on steroids. Anytime we need to match data with a little more clarity than the *s and ?s that windows gives us, we have Regex. Regex has a reputation for being difficult and confusing, but it really isn't so bad when you get used to it. The biggest contributors to Regex's reputation are: With that in mind, let's take a look at a sample about why you ...

PowerTip: Determine your version of PowerShell and host operating system
Jun 29, 2018
Post comments count 0
Post likes count 0

PowerTip: Determine your version of PowerShell and host operating system

Doctor Scripto
Doctor Scripto

Identify your PowerShell environment by making use of built-in PowerShell variables.

Windows PowerShell and the Text-to-Speech REST API (Part 5)
Jun 29, 2018
Post comments count 0
Post likes count 0

Windows PowerShell and the Text-to-Speech REST API (Part 5)

Doctor Scripto
Doctor Scripto

Send and receive content to the Text-to-Speech API with PowerShell.

PowerShell PowerTip: Checking your PowerShell version
Jun 26, 2018
Post comments count 0
Post likes count 0

PowerShell PowerTip: Checking your PowerShell version

Kory Thacher
Kory Thacher

If there is one question I could say I get the most in PowerShell, it is: How do I check my version? Its not a hard thing, but its not an obvious thing. We can actually check our version with a build in variable called PSVersionTable Hope that helps, tune in more often to get short and sweet PowerTips!

PowerShell For Programmers: Here Strings, There Strings, Everywhere Some String Strings
Jun 19, 2018
Post comments count 0
Post likes count 0

PowerShell For Programmers: Here Strings, There Strings, Everywhere Some String Strings

Kory Thacher
Kory Thacher

There won't be much code in today's post, but this can be a useful feature to know about. In addition to the expandable and literal strings we talked about, we can also use something called a Here String. Here strings allow us to have quote characters inside of our string that match the quote characters we use to create that string. For example, you might want the double quote character to appear inside of your expandable-string. You could use the escape character on the internal quote to prevent it from closing your string, but if you had a massive amount of quotes this would be annoying. Here strings exis...

PowerTip: Use PowerShell to play WAV files
Jun 15, 2018
Post comments count 0
Post likes count 1

PowerTip: Use PowerShell to play WAV files

Doctor Scripto
Doctor Scripto

Make use of the native features of Windows through PowerShell to play sound.

Windows PowerShell and the Text-to-Speech REST API (Part 4)
Jun 15, 2018
Post comments count 0
Post likes count 0

Windows PowerShell and the Text-to-Speech REST API (Part 4)

Doctor Scripto
Doctor Scripto

Send and receive content to the Text-to-Speech API with PowerShell.

PowerShell PowerTip: Grabbing the location your script lives in
Jun 12, 2018
Post comments count 0
Post likes count 0

PowerShell PowerTip: Grabbing the location your script lives in

Kory Thacher
Kory Thacher

One super common thing in PowerShell is to design a script to consume particular files for data. Often times you are building the script right in the folder for your files. However, it can be annoying to give long, literal file paths to a file. Also, if you give that script to someone else, they need to edit that path to point at the right location-- how annoying! There is a built in variable to help with this scenario: $PSScriptRoot will provide the file path the script was run from, which can let you relatively point at files. You can see an example of this in an older blog post. I received a few questions ab...

Working with JSON data in PowerShell
Jun 5, 2018
Post comments count 1
Post likes count 7

Working with JSON data in PowerShell

Kory Thacher
Kory Thacher

Welcome back everyone! This week we will take another look at some common data types we might encounter in the real world: JSON data. JSON data is used pretty frequently on the web if you're hitting APIs. This not only includes external data (twitter, weather, marvel database), but often includes internal data to your company. It's nice to be able to leverage data from anywhere, and it can be frustrating for people to try to parse JSON data. Luckily, we have this all built in for you using ConvertFrom-JSON I'll get a response from an API online used for testing: The response data looks like this: A...

PowerTip: Ensure that errors in PowerShell are caught
May 31, 2018
Post comments count 0
Post likes count 1

PowerTip: Ensure that errors in PowerShell are caught

Doctor Scripto
Doctor Scripto

Here’s how to make sure your errors get caught with <strong>Try Catch Finally</strong>.

Windows PowerShell and the Text-to-Speech REST API (Part 3)
May 31, 2018
Post comments count 0
Post likes count 0

Windows PowerShell and the Text-to-Speech REST API (Part 3)

Doctor Scripto
Doctor Scripto

Use Windows PowerShell to access the Cognitive Services Text-to-Speech API.

PowerShell PowerTip: ISE crashing and auto complete not working
May 30, 2018
Post comments count 0
Post likes count 0

PowerShell PowerTip: ISE crashing and auto complete not working

Kory Thacher
Kory Thacher

Hi all, I'm going to start putting out these short PowerShell PowerTips every so often. They won't be full blog posts, but they will be short and useful! Have you been having issues with the ISE crashing and not auto completing since windows update 1803? From what I've seen there is a fix for this coming, but if you need these features now you can try the 2016 ISE preview To try it run as an admin and do this: Then go ahead and pin it while you wait for the fix. You can also check out VS Code Happy PowerShelling!

Run PowerShell code in Puppet
May 23, 2018
Post comments count 0
Post likes count 0

Run PowerShell code in Puppet

Doctor Scripto
Doctor Scripto

Normally, it’s preferable to use specific Puppet and DSC Windows modules to manage systems in Puppet, but an alternative is running PowerShell commands and scripts by using the <strong>exec</strong> resource. This can be helpful for transitioning existing PowerShell code into Puppet quickly.

Doing more with functions: Verbose logging, Risk mitigation, and Parameter Sets
May 15, 2018
Post comments count 0
Post likes count 1

Doing more with functions: Verbose logging, Risk mitigation, and Parameter Sets

Kory Thacher
Kory Thacher

Welcome back to PowerShell for Programmers, this week I'm trying gitGist again for the code blocks. Let me know what you think about it vs the normal syntax highlighter I use :) As we've seen in the other posts about functions, attributes are a really cool thing to extend the features we have available to ourselves and for our users. This post is going to deal with an attribute for the function itself as well as ones for the individual parameters. This will let us make our functions behave more like any other cmdlet, by giving us access to the common parameters that users are used to seeing. Common Parameters...

PowerTip: Get all your local certificates by using PowerShell
May 9, 2018
Post comments count 0
Post likes count 0

PowerTip: Get all your local certificates by using PowerShell

Doctor Scripto
Doctor Scripto

How can I use Windows PowerShell to enumerate all certificates on my Windows computer?

Get certificate info into a CSV by using PowerShell
May 9, 2018
Post comments count 3
Post likes count 0

Get certificate info into a CSV by using PowerShell

Doctor Scripto
Doctor Scripto

Summary: Certificate management is always challenging. Let’s explore how to use PowerShell to export local certificate information to a comma-separated values (CSV) file on Windows 7 (or later) computers. Q: Hey, Scripting Guy! How can I get all my certificate info into a CSV on my Windows computers? —SH A: Hello SH, Patrick Mercier here, with my first “Hey, Scripting Guy!” post. This question has come up at multiple customer sites, as they plan a new PKI infrastructure or a revamp of their current one! There’s tons of resources on using PowerShell for querying certificates, but questions around finding exp...

Grabbing Excel (XLSX) values with PowerShell
May 8, 2018
Post comments count 0
Post likes count 1

Grabbing Excel (XLSX) values with PowerShell

Kory Thacher
Kory Thacher

The Goal: Import data from XLSX files conveniently like import-csv lets you do with simpler data. The preamble: Excel is a mainstay of the business world at this point, which means a lot of the data you might have to work with will come at you as an XLSX file or need to be one. This can be a bit annoying when scripting. If we're just working in PowerShell-land and we can choose to use simple CSV data we have the handy import-csv and export-csv cmdlets, and those CSV files can open up in excel just fine. However, when we are forced to work with XLSX files it can lead to headaches. If you search around ...

Doing More With Functions: Comment-Based Help
Apr 24, 2018
Post comments count 0
Post likes count 0

Doing More With Functions: Comment-Based Help

Kory Thacher
Kory Thacher

I just wanted to throw together a post highlighting how cool and easy it is to add help data to your own Functions and scripts. The help data gets added via comments. For functions the help data can go in three places: For scripts we just put it at the top of your script before you type the param() statement, or at the bottom, but the bottom will mess with code signing. Syntax just involves using a dot before the help keyword and then typing the help you want for it on the next line: Here is a list of all the keywords I found and short descriptions of them: For the most part, I recomm...

Inserting new elements into XML files
Apr 10, 2018
Post comments count 0
Post likes count 0

Inserting new elements into XML files

Kory Thacher
Kory Thacher

The Goal: Insert nodes into a specific place in XML config files The Motivation: I had a coworker a while back working with App Fabric. He needed to insert a particular chunk of XML into a specific spot inside of the config file. This had to be done on a bunch of different machines, but the kicker was that the config files might look different on all of them. We knew the node that needed to come before our new node, but that might be in a different spot in each file. When the configSections node ended ( </configSections> ) we needed to insert: This is the perfect place for PowerShell auto...

Introducing the DscLcm utility for PowerShell
Mar 30, 2018
Post comments count 0
Post likes count 0

Introducing the DscLcm utility for PowerShell

Doctor Scripto
Doctor Scripto

Summary: Desired State Configuration is a great deployment tool to meet your organization’s infrastructure-as-code goals. I recently came across a situation for a project that uses the Push Service (as opposed to the Pull Service). It required me to be able to apply a new partial configuration to a node, without any knowledge of what partial configurations were already in place. This led to the development of the DscLcm module, which solved that problem for my team. DscLcm module The DscLcm PowerShell module is a utility that interacts with the Local Configuration Manager (LCM) of a target machine. You don’t have...

Doing More With Functions: Taking Parameters on the Pipe
Mar 27, 2018
Post comments count 0
Post likes count 1

Doing More With Functions: Taking Parameters on the Pipe

Kory Thacher
Kory Thacher

In an earlier post, I showed you how you could use the [parameter(mandatory)] attribute to force your parameters to behave  a bit more like you'd expect from other languages. We also have a bunch of other useful attributes we can use on our parameters to enable cool features. Pipelineing The pipe might feel pretty magical to you in PowerShell, as it just seems to work with our built in cmdlets. You can add this same kind of functionality to your own tools, and we give you two options to do so. First of all, here is what happens if you don't use this attribute: Pipeline By Value When we talk about stuff...

PowerTip: Build simple HTML with PowerShell
Mar 15, 2018
Post comments count 0
Post likes count 0

PowerTip: Build simple HTML with PowerShell

Doctor Scripto
Doctor Scripto

Summary: Here’s how to use the ConvertTo-HTML cmdlet to build basic HTML content.   Hey, Scripting Guy! Occasionally I need to build basic HTML documents. I heard there was a way to do that with Windows PowerShell.   There most certainly is! Just use the ConvertTo-HTML cmdlet to save the day! For example:                           $SampleDoc=@'                           This is a simple text Document in PowerShell                           That I am going to make into a Tiny web page                           :)                           '@                           ConvertTo-Html -InputObject $SampleDoc      ...

Windows PowerShell and the Text-to-Speech REST API (Part 2)
Mar 15, 2018
Post comments count 0
Post likes count 0

Windows PowerShell and the Text-to-Speech REST API (Part 2)

Doctor Scripto
Doctor Scripto

Summary: You can use Windows PowerShell to authenticate to the Text-to-Speech REST API. Q: Hey, Scripting Guy! I was reading up on the REST API for the Text-to-Speech component of Cognitive Services. I'm just starting to learn how to use REST and PowerShell. Could you spend a little bit of time and show me how to authenticate to the service? —SH A: Hello SH, Authentication is one of the biggest pieces you'll want to learn. Telling a system at the back end who you are, and knowing how to communicate with it, is very critical before you can do anything fun! Talking to the Text-to-Speech API is pretty easy onc...

PowerShell for Programmers: The Magic Switch!
Mar 14, 2018
Post comments count 0
Post likes count 2

PowerShell for Programmers: The Magic Switch!

Kory Thacher
Kory Thacher

Welcome back everyone, I'm trying out GitHub Gist for my code blocks this week. It lets you click and download them, as well as making them easy to edit. The downside is that I can't use my usual dark themed syntax highlighting. Let me know in the comments if you like gist or the old method better :) Switch statements in PowerShell are very cool, and by knowing some of the tricks it has in place it can save you a lot of time. Basic Syntax Let's start by taking a look at a basic switch statement. In C# you might write something like this: In PowerShell you could do this: Notice we don't use t...

PowerShell For Programmers: Strings, Quotes and Quirks
Mar 1, 2018
Post comments count 0
Post likes count 0

PowerShell For Programmers: Strings, Quotes and Quirks

Kory Thacher
Kory Thacher

Welcome back everyone! This will be a short, but important entry for the guide. The difference between quote characters is something I’m asked about all the time. It is important to understand in PowerShell, but most of the time it probably won’t make a difference. TLDR: If you're just typing a value like "alg" then it doesn't matter, but if you have any special symbols you can see the difference. Single vs. Double Quotes We refer to single quotes as Literal Strings and double quotes as Expandable Strings. Both create the same datatype (system.string), but a double quote will expand any special charact...

PowerTip: Create new authentication keys for AzureRM Cognitive Services
Feb 28, 2018
Post comments count 0
Post likes count 0

PowerTip: Create new authentication keys for AzureRM Cognitive Services

Doctor Scripto
Doctor Scripto

Summary: Change the keys to authenticate to Azure RM Cognitive Services, by using Windows PowerShell.   Hey, Scripting Guy! I created the keys for my Rest API. I know I can change them in the web portal, but is there a faster way of doing it through Windows PowerShell?   There absolutely is! Just use the New-AzureRMCognitiveServicesAccountKey cmdlet to reset either Key1 or Key2 (or both). Here is an example, where we generate a new sequence for Key1: New-AzureRMCognitiveServicesAccountKey -ResourceGroup 'HSG' -Name 'Sample' -KeyName Key1

Windows PowerShell and the Azure Text-to-Speech Rest API (Part 1)
Feb 28, 2018
Post comments count 0
Post likes count 0

Windows PowerShell and the Azure Text-to-Speech Rest API (Part 1)

Doctor Scripto
Doctor Scripto

Summary: You can use Windows PowerShell to authenticate to the Microsoft Cognitive Services Text-to-Speech component through the Rest API. Q: Hey, Scripting Guy! I heard about the cool Microsoft Cognitive Services, and had heard they have a REST API. Does that mean I can use PowerShell to consume them? Could you show me how to authenticate to it? —SH A: Hello SH, I just love waking up and saying "YES YOU CAN!" when people ask "Can you do that with Windows PowerShell?" So… ahem…. "Yes you can!" For those who didn't know, Cognitive Services are hosted in the Azure cloud, and they allow you to many things eas...

PowerTip: Use PowerShell to read an RSS feed
Feb 21, 2018
Post comments count 0
Post likes count 0

PowerTip: Use PowerShell to read an RSS feed

Doctor Scripto
Doctor Scripto

Summary: “Hey, Scripting Guy!” shows you how to use Invoke-RestMethod to read a list of entries from an RSS feed.  How can I use Windows PowerShell to see the list of articles from an RSS feed?       Just use the Invoke-RestMethod and provide the full path to the link to the RSS feed. Here is an example:    Invoke-RestMethod -Uri 'https://blogs.technet.microsoft.com/heyscriptingguy/rss.aspx  

PowerShell and the REST API for the IT pro
Feb 21, 2018
Post comments count 0
Post likes count 0

PowerShell and the REST API for the IT pro

Doctor Scripto
Doctor Scripto

Summary: This post provides a quick introduction to what the REST API is, and how it applies to Windows PowerShell. Q: Hey, Scripting Guy! I can see there is this cool cmdlet called Invoke-RestMethod. I've been told REST API's are all around, and this allows me to consume that data. Could you give me a hand getting started? —SH A: Hello SH, Glad to help out! I remember hearing about REST APIs the first time, thinking they might be a way to take a nap at work. Was I wrong on that one! What a "REST API" is at the most BASIC level is really just a very fancy web Endpoint. You could, if you were really creative, t...

PowerShell for Programmers: How to write a function the right way
Feb 15, 2018
Post comments count 0
Post likes count 3

PowerShell for Programmers: How to write a function the right way

Kory Thacher
Kory Thacher

Just like I mentioned in my first post, PowerShell supports a lot of stuff that makes it pretty easy to dive in and get stuff running. The following two examples are supported in PowerShell, but not something you should really be doing for any reusable tool set. Putting your parameters (arguments) next to the function name in parenthesis is pretty standard in most languages, but in PowerShell it will limit your functionality. Similarly, $args will stop working for you if you add some of those more useful features, but I’ll show you a way to mimic the functionality on your own later. So, how should you b...

PowerShell for Programmers: What happened to my operators?
Feb 1, 2018
Post comments count 0
Post likes count 2

PowerShell for Programmers: What happened to my operators?

Kory Thacher
Kory Thacher

Operators are one of the most frustrating things about learning PowerShell if you’re coming from just about any other language in existence. Operators like ==, <=, !=. etc. are almost ubiquitous in programming, but none of them are supported in PowerShell. This can lead to some pretty frustrating errors with things like If statements. You might see:   In PowerShell we are still going to have all these operators, they are just going to look different, using dashes and vaguely resembling parameters. I wondered the reason behind this myself for a while, and made a pretty inaccurate guess, but...

PowerShell for Programmers: Basic Syntax – Variables, Objects, and Data Types
Jan 18, 2018
Post comments count 0
Post likes count 2

PowerShell for Programmers: Basic Syntax – Variables, Objects, and Data Types

Kory Thacher
Kory Thacher

Variables Variables in PowerShell are going to be a bit different than they are for you in most languages. To start out the conversation, the basic way to create a variable is just by using a “$” and an “=”, but there are cmdlets and other ways to generate them.   Objects Objects are going to work how they do most places. Dot notation lets us dig into their properties and methods. If you want to see your object’s members, we have several options: 1. Get-Member: you’ll notice the definitions look a lot like you’re used to in C-based lang...

PowerShell for Programmers: A Quick Start Guide
Jan 4, 2018
Post comments count 0
Post likes count 3

PowerShell for Programmers: A Quick Start Guide

Kory Thacher
Kory Thacher

Now that my content has been migrated to the scripting blog, this will be the landing page for the series and I'll be trying to update all the links.  Learning PowerShell can be very useful for people with programming experience. Whether you’re currently a developer, dev-ops, or an admin you can get some serious use out of being familiar with PowerShell. You might think its just a version of command prompt with an eye-burning color scheme, but it really is a full scripting language with lots of nice tie ins. PowerShell is geared towards IT admins and made easy to learn with lots of nice shortcuts, and auto-...

PowerShell For Programmers: Basic Syntax — CMDLETs
Jan 4, 2018
Post comments count 0
Post likes count 4

PowerShell For Programmers: Basic Syntax — CMDLETs

Kory Thacher
Kory Thacher

PowerShell might look really strange to you. Many people assume PowerShell is basically CMD-prompt 2.0 because of the way it looks, but it really is a fully operational scripting language underneath. PowerShell has something called a cmdlet (command-let), which for the most part is the same idea as functions you're used to from other languages. I'll assume you're coming from a more classic language and you're used to calling functions like this: If you've been using cmdlets in PowerShell like this, you've been doing it wrong. This could cause you some serious problems down the line. "But I can type ...

Cross-platform PowerShell remoting in action
Dec 29, 2017
Post comments count 0
Post likes count 0

Cross-platform PowerShell remoting in action

Doctor Scripto
Doctor Scripto

Summary: Learn how to configure and use cross-platform PowerShell remoting in PowerShell Core. I’m Christoph Bergmeister, a London-based full stack .NET software developer with a passion for DevOps. To enable product testing of .NET Core apps across non-Windows machines in CI, I was one of the first people to use the new cross-platform remoting capabilities based on an integration of OpenSSH with PowerShell Core. In the early days, setup was very tedious, and as part of my journey I had to experiment a lot to get everything working together nicely. Today, I want to share with you some of what I learned. Introduc...

Script Wars: The Farce Awakens (part V)
Dec 22, 2017
Post comments count 0
Post likes count 0

Script Wars: The Farce Awakens (part V)

Doctor Scripto
Doctor Scripto

Summary: Rey is skilled in PowerShell, and new to Contoso Holly Jolly Hat Company. Already she has been a great boon to her new co-workers and had her sneakers become the subject of a hungry trash robot. She was just about to walk out to the hall with Ben Kerberosie, when suddenly an dominant figure has blocked them, with the following words booming through the hall: "WHO DO I SPEAK TO ABOUT CLEAR TEXT PASSWORDS in POWERSHELL!?!" ---------------------- That entity was none other than Katherine Phantampa! Head of IT Security, and also known as The Gatekeeper. The Protector of Data. The Guardian of all that was...

Script Wars: The Farce Awakens (part IV)
Dec 21, 2017
Post comments count 0
Post likes count 0

Script Wars: The Farce Awakens (part IV)

Doctor Scripto
Doctor Scripto

Summary: A quick recap shall we? Newly graduated from IT training and future guru in the world of Windows PowerShell, Rey Skyworker has been hired on by her mentor, Ben Kerberosie. Already, she has helped peers from her team improve their PowerShell code to do some basic error trapping and cleanup of the data upon entry. Not bad for somebody on their first day, eh? Oh, almost forgot, her shoelaces have been chosen as lunch by a new Beta cleaning robot with more suction than common sense. Shall we continue? Let's! -------------------------- Tin has been left back to tend to the help desk, while Ben continues ...

Script Wars: The Farce Awakens (part III)
Dec 20, 2017
Post comments count 0
Post likes count 0

Script Wars: The Farce Awakens (part III)

Doctor Scripto
Doctor Scripto

Summary: When last we saw our hero, Rey Skyworker, she was aiding her new co-worker, Tin. They managed to implement better error trapping by using the "Try Catch" statement in Windows PowerShell. The fact they could do this so easily it has tickled Tin's curiosity. ---------------------------- "Now Rey, I'm looking at this and as I see it, I could avoid the error altogether by trapping for those situations. Maybe adding in a few IF statements like this to the script." If (($First -or $Last)) -eq '') then { Write-Output 'Names cannot be blank } Else { ….rest of the script } Rey nodded. "You mean adding ...

Script Wars: The Farce Awakens (part II)
Dec 19, 2017
Post comments count 0
Post likes count 0

Script Wars: The Farce Awakens (part II)

Doctor Scripto
Doctor Scripto

Summary: Yesterday, we met a newly graduated IT professional, Rey Skyworker, as she discussed the ways of "The Farce." It was during this discussion that her instructor, Ben Kerberosie, discovered she had a natural gift in understanding how to implement some good practices into writing her scripts. Today, we sit quietly (I mean all of you in the back too, no chattering and tossing about popcorn!), as Rey is about to embark on her new job. The position: on the help desk. The company: Contoso Holly Jolly Hat Company. She is being introduced to her new co-worker on the help desk, Jeremy Tinnison. ---------------...

Script Wars: The Farce Awakens (part I)
Dec 18, 2017
Post comments count 0
Post likes count 0

Script Wars: The Farce Awakens (part I)

Doctor Scripto
Doctor Scripto

Summary: Seven years ago, “Hey, Scripting Guy!” was approached by a member of the community to see if we would be interested in doing something a little fun for the holidays.  The result was a seven-part series called “A PowerShell Carol.” So when we were approached continuously in following years, we allowed this madness to continue! The tradition continued on with the "Blues" in Blueville and Curly Blue, amongst others, doing a twist on popular holiday stories. The community even dared to touch upon classic tales, with "Oliver Script," a "twist" on another famous story by Mr. Dickens. And now, we bring you th...

PowerShell support for certificate credentials
Dec 15, 2017
Post comments count 0
Post likes count 0

PowerShell support for certificate credentials

Doctor Scripto
Doctor Scripto

Summary: It's not a very well-known feature, but the PSCredential object, and the PowerShell Get-Credential cmdlet, both support certificate credentials (including PIN-protected certificates). In this post, we take a look at how a certificate credential is marshaled inside a PSCredential object, how you can do this marshaling yourself, and how you can retrieve the original certificate from a PSCredential object supplied to you. Most Win32 APIs that support the PSCredential object for credential validation already support certificates. However, if your code currently consumes a PSCredential, and you use the user ...