Saturday, March 23, 2013

Registry Identity Check

Excuse me, mister computer, just who in hades are you?

Kind of helps to answer that question with identity keys that are created in the registry and then discovered

                       function Check-machine-registry
                     {
                             try
                            {
                                [System.Boolean]$rt = $false
                                $Name = "KeyValueName"
                                $Path = "HKLM:\SOFTWARE\Some registry key path"
                                $key = Get-Item $Path  -ErrorAction SilentlyContinue
                                $value = $key.GetValue($Name)
                                if ($Value -ne "KeyValue")
                                {
                                    return $rt
                                }
                                $Name1 = "KeyValueName"
                                $Path1 = "HKLM:\SOFTWARE\Some registry key path"
                                $key1 = Get-Item $Path  -ErrorAction SilentlyContinue
                                $Value1 = $key1.GetValue($Name1)
                                if ($Value1 -ne "KeyValue")
                                {
                                    return $rt
                                }
                                $rt = $true
                                return $rt 
                            }
                            catch
                            {
                                return $rt
                            }
                    }

No comments:

Post a Comment