Command 3) Get-WmiObject -Class Win32_UserAccount -Filter “LocalAccount=‘True’” | Select name -expandproperty name
Command 4) Get-ChildItem -Path C:\Users\ | select-object Name
<li>Q1. Is anyone able to add my commands to an example for me to play with?</li>
<li>Q2. I have to run this against computers (200+) within a domain. There are only a few systems with WSMan enabled, I will need to look at that on a separate note. If WS Man was enabled across all systems, would invoke-command would be the best option?</li>
As my script stands, I can Enter-PSSession and manually RUN the script against a remote PC, but I want to do this against ALL my computers.
Whenever i am looking to grab information from several systems, i usually do it one of 2 ways, either i create a csv,txt file with the list of systems i want to check against, i then load that information into a variable and run it through a Foreach loop with the code you want in the middle.
The other way, is still using a foreach, but harcode the Computers into a variable, then run the loop against this. I find that CSV/Txt is easier for me personally.
I like using CIM sessions when working with WMI. The computers can be a list like above or you can use a Get-ADGroupMember or any number of options to populate this variable. Using the protocol DCOM will allow you to connect to computers that do not have the most current PowerShell installed.
CIM Sessions are made concurrently so the collection of the profile data is quicker. If you run Get-CIMSession after the third line you will see a listing of the sessions. Plenty of information on the web on this - I think Don Jones has a few great videos on YouTube or the PowerShell videos on Microsoft Video Academy (free).
All of that data gets stored into the $profile variable. From there you can pull out what you need.