Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Validation of missing permission when using Get-WmiObject before execution

$
0
0

Hi,

How can i validate permissions befor running Get-WmiObject execution and get a true or false value that everything is okay?

$x = "Something"
if($x -eq "true"){

$LocalUsers = Get-WmiObject -Class Win32_UserAccount -Namespace "root\cimv2" -Filter "LocalAccount='$True'" -ComputerName "ServerName"

$Permisson = "OK"

}else{

$Permisson = "FAILD"

}

Write-Host $Permisson


Viewing all articles
Browse latest Browse all 6937

Trending Articles