![powershell microsoft.win32.registrykey openremotebasekey credentials powershell microsoft.win32.registrykey openremotebasekey credentials](https://boeprox.files.wordpress.com/2013/09/image_thumb3.png)
The type indicates whether the value is STRING, DWORD, or BINARY. It also determines the type of the key by using the GetValueKind method.
#Powershell microsoft.win32.registrykey openremotebasekey credentials code
When it is found, the variable $flag is set to $true and the following code queries the value of the registry key property using the GetValue method.
![powershell microsoft.win32.registrykey openremotebasekey credentials powershell microsoft.win32.registrykey openremotebasekey credentials](https://i1.wp.com/www.jaapbrasser.com/wp-content/uploads/2016/05/RemoveUpgradeFiles.png)
After obtaining the object of the registry subkey, we need to query all the key properties inside the subkey to find out if the key we are querying is present. After connection has been established successfully, we can directly navigate to the sub registry key that stores the value we are looking for. When the connection initializes, we need to provide two variables: the computer name and the base key (for example, LocalMachine or LocalUser). I am using the base class for connecting to the remote registry. This part of the script connects to the remote base registry and navigates to the required sub registry key. Now let us enter the main part of the script. "HKEY_LOCAL_MACHINE" Connect to the remote computer and retrieve the key ^ A switch statement processes the basekey value and generates the equivalent string that the class can understand. Split the registry key ^Īfter processing the parameters, I use a regular expression to separate basekey and subkey. If the parameter is not set, the script will operate on the local computer. If you want to retrieve the registry key of a remote computer, you also have to provide a value to the –ComputerName parameter. If you want to query the value of AutoAdminLogon, you have to submit both parts as parameters to the script. The “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\” part is the RegistryKey the remaining part, “AutoAdminLogon,” is the KeyProperty. The key decides if automatic logon is active, and it has two possible values (enabled/disabled).