06 November 2020

Invoke-Command and local variables in PowerShell

Just use "using:" before the variable name

$abc= 'some text'
icm servername {'----';echo $abc;'----'}
icm servername {'====';echo $using:abc;'===='}

Here we set the local variable with the name $abc to some value. When using Invoke-Command (alias icm), then first version uses remote version of that variable, which probably is empty and second version kinda drags the local variable to remote session and you can use it there.


 How to generate pronouncable password using PowerShell

Paste following two lines into an Administrative PowerShell and here you go:

Install-Module MlkPwgen -ErrorAction SilentlyContinue
New-PronounceablePassword -Digits



03 November 2020

 How to work with printers like PowerShell guru

If you are lost finding printer listing in Windows 10, just open powershell and type the following:

Get-Printer | ogv

If you want to delete one of them:

Get-Printer | ogv -PassThru | Remove-Printer

Just select one of them in the Out-Gridview window and press OK and it will be deleted