Wow!  It has been a
while since I last blogged.  This has
been a very busy year. Between my Navy activities and all the classes that I’m
bringing online for clients, I am burning the candle at both ends.
As many of you know, my last day of a PowerShell class is “Project
Day”.  One of the projects that I helped
out with this week involved determining if UAC was enabled.  Utilizing the template we created in class
and a check of the registry, we were able to:
- Remote to each client.
- Determine if the client was online.
- Report back the state of UAC.
I decided to advance the code just a little to make sure
everything reports back as an object. 
Below is that code.  Wish I had
more time to explain it step by step, but I have to keep moving.  I only have 3 weeks to get everything done
for PowerShell Conference Europe.
ForEach ($N
in (Get-ADComputer
-filter *).Name)
{
    $Obj = New-Object -TypeName PSObject
-Property @{
        ComputerName =
$Null
        UACEnabled =
$Null
        Online =
$False
    }
    Try
    {
        $Obj.ComputerName =
$N
        $Data
= Invoke-Command
`
                -ComputerName
$N `
                -ErrorAction
Stop `
                -ScriptBlock
{
                    (Get-ItemProperty
`
                        -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System
`
                        -Name EnableLUA).EnableLUA 
                } 
        $Obj.Online = $True
        If
($Data =
1) {$Obj.UACEnabled =
$True}
        Else
{$Obj.UACEnabled
= $False}
    }
    Catch {$Online = $False}
    Write-Output
$Obj
} 
Comments