Monthly Archives: July 2019

Unblock and unzip

When you download a zip file from the Internet you have to unblock and unzip the file. I need to do this fairly often so wrote this simple function to perform both actions rather than doing it manually. function unzipfile … Continue reading

Posted in Powershell | Leave a comment

Variables in scriptblocks

I often see questions regarding the use of variables in scriptblocks. Usually a variable will be defined outside the scriptblock and then an attempt will be made to use it in the scriptblock: PS> $path = ‘C:\test\OldData01.txt’ PS> Start-Job -Name … Continue reading

Posted in Powershell | Leave a comment

Test local user doesn’t exist before creating

Saw a question asking how to Test local user doesn’t exist before creating.  Windows 8 introduced the LocalAccounts module for Windows PowerShell. On Windows 10 1903 it runs in PowerShell v6/7. There isn’t a Test-Localuser cmdlet but you can attempt … Continue reading

Posted in Powershell | Leave a comment

Missing verbs?

I saw a post that suggested that you can’t use Sort as a verb in your functions. You get a message that sort is an unapproved verb. Are there any other missing verbs? I started with the object cmdlets as … Continue reading

Posted in Powershell | Leave a comment

Sddl

An Sddl is a Security Descriptor Definition Language string – https://docs.microsoft.com/en-us/windows/win32/secauthz/security-descriptor-definition-language – that provides a succinct way to provides the security descriptor of an object as a string. An example Sddl would be O:BAG:S-1-5-21-437587817-63618879-1935034000-1001D:AI(A;ID;FA;;;SY)(A;ID;FA;;;BA)(A;ID;0x1200a9;;;BU) Now I’m sure that’s totally clear … Continue reading

Posted in Powershell | Leave a comment

Sort direction

By default Sort-Object uses an ascending sort direction. Get-Command | Sort-Object -Property Source will sort the commands based on the Source (module) in ascending Source order. If you use multiple properties Get-Command | Sort-Object -Property Source, Name, Version Your output … Continue reading

Posted in Powershell | Leave a comment

Volume friendly name

When you use Get-Volume one of the properties displayed is the friendly name PS> Get-Volume -DriveLetter C DriveLetter FriendlyName FileSystemType ———–     ————          ————– C                                                NTFS In this case its blank because I haven’t set a volume label. If you try … Continue reading

Posted in PowerShell and CIM | Leave a comment