PowerTip: Get a list of local Users in Windows 10 / Windows Server 2016

Summary: Use the cmdlets provided in PowerShell 5.1 to manage local user accounts on a system. I remember having to use the Active Directory Service Interfaces (ADSI) accelerator to access a list of local users in PowerShell. Is there a cmdlet that could do this now? Yes.  In the most recent version of Windows 10…


PowerTip: Use PowerShell to determine active CIM sessions

Summary: Use the Common Information Model (CIM) cmdlets to pull a list of active sessions to remote workstations. How can I find active CIM sessions on my workstation? Just use this one cmdlet to list all active CIM sessions, and you’re done for the day! Get-CimSession


PowerTip: List locked-out accounts in Active Directory with PowerShell

Summary: Use Active Directory cmdlets to identify locked-out user accounts and computer accounts. Is there a quick and easy way to find all users who are locked out in Active Directory by using PowerShell?   You’ll love this. The answer is just one cmdlet away with the ActiveDirectory module. Just use Search-ADAccount, and you’ll have…


PowerTip: Limit Get-Childitem to a limited depth in the tree

Summary: Use the new -depth parameter to control how far down a directory you can search. I have a large file structure to search but I only want to go two folders deep on the search.  Is there a way to do this in PowerShell? Certainly!  In PowerShell 5.0, you can use the -depth parameter…


PowerTip: Capture the output of a Linux application in PowerShell

Summary: Use the built-in features of PowerShell to obtain data produced by a Linux application. Can I run a Linux application like ls and capture its output in PowerShell? You certainly can!  It’s no different from when you normally grab output from any other command in Windows.   To grab the output of the ls command,…


PowerTip: Return a status code to Linux from PowerShell

Summary: Pass a result code back to a calling Linux environment from Open Source PowerShell. How can I pass a numeric value back to a calling Bash Shell to indicate an error? Just simply supply the EXIT command and a numeric value at the point where the error is flagged. For example, the following code…


PowerTip: Get the status code of a PowerShell script in Bash

Summary: Identify the results of a script running in Open Source PowerShell in a Bash environment. Is there any way to see the results of a PowerShell script? For example, if somebody sent an “Exit 42”, could I see it in Linux? All you need to do is examine the $? variable in Linux, just…


PowerTip: Capture error code of a PowerShell session in Linux or macOS

Summary: Capture the status code of a PowerShell session in Linux or macOS. Could you show me how to run a PowerShell script in Linux or macOS and capture the status of whether that script succeeded or failed? No problem, my friend. Just run the PowerShell session, and start the script as in the following…


PowerTip: Know the difference between the .split() method and ‘-split’

Summary: Cloud and Datacenter Management MVP, Thomas Rayner, shows how to split a string by using a string instead of just a character. I am trying to split the string “this is my amazing string” on the pattern “my” by using “this is my amazing string”.split(“my”) but it’s giving me a bunch of garbled stuff…