Good morning folks..
I have a (hopefully) quick question on how to do add a target to certain PowerShell commands that don't allow the "-Computername $Target" option.
Things like below... How would I be able to run my script I have that finds out a bunch of important info on a machine, and get info on a target machine:
Write-Output "..Windows Product Key"
$prodkey = (gwmi -ComputerName $Target -query ‘select * from SoftwareLicensingService’).OA3xOriginalProductKey
Write-Output "..Local User Listings"
$users = Get-LocalUser | Sort-Object Name
Write-Output "..Group Memberships"
$groups = Get-LocalGroup | Sort-Object Name
Write-Output "..WSUS Server Configuration"
$WSUSServer = (Get-ItemProperty -Path HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate).WUServer
As you can see, I utilize the $Target variable on things that I know will work like the gwmi and it works flawlessly. But other things I have listed above I can't figure out how to point them to another machine I am trying to run the script from.
For instance... I am running a PowerShell script from one of my domain controllers, because every vLAN in that specific environment is open from the domain controllers. So instead of having to log in to each and every single machine (over 3,000) individually, I can set up a text file with say 15 or 20 servers at a time, run my information script, and return the results all from the domain controller.
Thanks in advance for the assistance.