Few PowerShell Functions Around Windows Security

As parts of the PowerShell project that I’m currently working on, with the help with other people’s contribution in various forums and blogs, I have produced few PowerShell functions around Windows security: Validate Credential [sourcecode language=”PowerShell”] function Validate-Credential($Cred) { $UserName = $Cred.Username $Password = $Cred.GetNetworkCredential().Password Add-Type -assemblyname System.DirectoryServices.AccountManagement $DS = New-Object System.DirectoryServices.AccountManagement.PrincipalContext([System.DirectoryServices.AccountManagement.ContextType]::Machine) Try { $ValidCredential = $DS.ValidateCredentials($UserName, $Password) } Catch { #if the account does not have required logon rights to the local machine, validation failed. $ValidCredential = $false } Return $ValidCredential } [/sourcecode] Usage: [sourcecode language=”PowerShell”] $MyCredential = Get-Credential $ValidCredential = Validate-Credential $MyCredential [/sourcecode] Get Current User Name [sourcecode

Continue reading

Changing Display Language on Windows 7 Home and Professional Editions

I bought a laptop for other family members yesterday, it comes with Windows 7 Home Premium. I needed to change the display language from English to Chinese because the main user of this laptop does not speak English. I thought it was a no brainer as I’ve done it before, all I had to do was to load another language pack in “Regional and Language” in Control Panel. However, I was wrong. apparently this function is available in Windows 7 Ultimate and Enterprise editions. I didn’t really want to use Windows Anytime Upgrade to upgrade it to Ultimate just so

Continue reading
%d bloggers like this: