Jump to content

PowerShell command


Valnurat
 Share

Recommended Posts

you could (search 'powershell and WMI'), but if its just a WMI query I would run that directly rather than wait for powershell to tell me.  Look up "scriptomatic" for all the fun you can do with WMI directly.

This thread also has a few powershell CIM-Instance examples:

 

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

I normally use something like:

_Get_ComputerObj(@ComputerName)

Func _Get_ComputerObj($_sComputerName)
    Local $sServerName = "SCCM Server", $sSiteCode = "3 Character Site Code"
    Local $oSWBEMLoc = ObjCreate("WbemScripting.SWbemLocator")
    Local $oConnectSrv = $oSWBEMLoc.ConnectServer($sServerName, "root\SMS\site_" & $sSiteCode)
        $sQuery = "SELECT * FROM SMS_G_System_COMPUTER_SYSTEM Where Name='" & $_sComputerName & "'"
        $oComputers = $oConnectSrv.ExecQuery($sQuery)
        For $oComputer In $oComputers
            MsgBox(32, "", "Computer Name: " & $oComputer.Name & @CRLF & "ResourceId: " & $oComputer.ResourceId)
        Next
EndFunc

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...