WMIC : Invalid Global Switch - The How and Why Cookbook
WMIC says "Invalid Global Switch"
Why does it say that when you use the /NODE switch? It's because WMIC really wants the full IP address of the remote computer, not the name.
Here's an example of it:
This is the right way to do it, to prevent "Invalid Global Switch"
The WMIC Cookbook
# --------- CUT HERE -----------------------
# A powershell script by Uncle Joe
# To append to the file, use /APPEND instead of /OUTPUT
$username="talladega\lets_go_brandon"
$password="Nascar22"
# Get Computer Name
wmic /NODE:192.168.0.143 /OUTPUT:a.out /USER:${username} /PASSWORD:${password} computersystem get model,manufacturer,name,username
# Disk Check
wmic /NODE:192.168.0.143 /APPEND:a.out /USER:${username} /PASSWORD:${password} logicaldisk list full
# CPU Check:
wmic /NODE:192.168.0.143 /APPEND:a.out /USER:${username} /PASSWORD:${password} cpu list brief
# Check Windows Updates
wmic /NODE:192.168.0.143 /APPEND:a.out /USER:${username} /PASSWORD:${password} qfe list full
# or
wmic /NODE:192.168.0.143 /APPEND:a.out /USER:${username} /PASSWORD:${password} qfe list brief
# Get OS Version
wmic /NODE:192.168.0.143 /APPEND:a.out /USER:${username} /PASSWORD:${password} os get version,caption,FreePhysicalMemory,BuildType
# --------- CUT HERE -----------------------
Before running powershell scripts, you need to do this first:
This example shows how to set the execution policy for the local computer.
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine
Get-ExecutionPolicy -List
Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser RemoteSigned
LocalMachine RemoteSigned
The Set-ExecutionPolicy
cmdlet uses the ExecutionPolicy parameter to specify the RemoteSigned
policy. The Scope parameter specifies the default scope value, LocalMachine
. To view the execution policy settings, use the Get-ExecutionPolicy
cmdlet with the List parameter.
Useful Commands Cookbook
Select Process Using the Most Memory
Use the Split Operator to cut up text
$text = "Description=The '=' character is used for assigning values to a variable" $name, $value = $text -split "=", 2 @" Name = $name Value = $value "@
Comments
Post a Comment