Tinus EngOps Wiki

Logo

OpsaC - Operating as PowerShell code

Links

Home

IT-Wiki

PowerShell Blog

PowerShell Index

PowerShell Search

Additional Websites

View my GitHub Profile

View my GitHub Gists

View my Codeberg Page

View my Photo Website

Read from WMI

published: April 28, 2019 author: Tinu tags: PowerShell categories: PowerShell-WMI


Table of Contents

Copy items from a local to a remote computer using a psremote-session.

Read-FromWMIClass

function Test-WMISetting {
    [cmdletbinding()]
    param(
        [Parameter(Mandatory=$false)]
        [Object]$args
    )
    $function = $($MyInvocation.MyCommand.Name)
    Write-Verbose $function

    $ret = $null
    try{
        $objret = (Get-WmiObject -Class $args.WMIClass)
        if($objret.($args.WMISetting)){
            $ret = $objret.Domain
        }
    }
    catch{
        $error.clear()
        $ret = $null
    }
    return $ret
}

$params = @{
    WMIClass     = 'win32_computersystem'
    WMISetting   = 'PartOfDomain'
}

return (Test-WMISetting -args $params)

See also

WMI Reference on Microsoft Docs.


← Previous Post ◇ [ Top ] ◇ Copyright © 2024 by tinuwalther ◇ [ Blog ] ◇ Next Post →