OpsaC - Operating as PowerShell code
published: April 28, 2019 author: Tinu tags: PowerShell categories: PowerShell-WMI
Copy items from a local to a remote computer using a psremote-session.
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)
WMI Reference on Microsoft Docs.