Get-RDPCertificate PowerShell Function
I’ve been on a PowerShell function writing kick lately. Finally have one somewhat polished. As the name implies, it gets information for the certificate being used by the RDP service.
https://github.com/ThePatrickHoban/Scripts/blob/main/PowerShell/Certificates/Get-RDPCertificate.ps1
Quick Post: Find Group with ManagedBy Set
I recently ran into an issue where the description of an AD group said “Can manage membership of groups listed in notes”. Unfortunately, the notes field was blank. To find what, if any group(s) could be managed by this group just takes a few simple lines of PowerShell.
The code is posted on my GitHub page.
Encoding & Decoding Base64 using PowerShell
Update: I updated this on 1/23/2020 to include UTF-8 as well. Originally I just showed Unicode. I have found that “things” are more often encoded in UTF-8.
# Encode string using Base64 $Text = "This was encoded using Base64" $EncodedUnicode = [Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes($Text)) $EncodedUTF8 = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($Text)) $EncodedUnicode VABoAGkAcwAgAHcAYQBzACAAZQBuAGMAbwBkAGUAZAAgAHUAcwBpAG4AZwAgAEIAYQBzAGUANgA0AA== $EncodedUTF8 VGhpcyB3YXMgZW5jb2RlZCB1c2luZyBCYXNlNjQ= # Decode Base64 to string $Base64Unicode = "VABoAGkAcwAgAHcAYQBzACAAZQBuAGMAbwBkAGUAZAAgAHUAcwBpAG4AZwAgAEIAYQBzAGUANgA0AA==" $Base64UTF8 = "VGhpcyB3YXMgZW5jb2RlZCB1c2luZyBCYXNlNjQ=" $DecodedUnicode = [System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String($Base64Unicode)) $DecodedUTF8 = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($Base64UTF8)) $DecodedUnicode This was encoded using Base64 $DecodedUTF8 This was encoded using Base64
Disable Automatic Updates for Power Query for Excel
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft Power Query for Excel]
“DisableUpdateNotification”=dword:00000001
or
New-ItemProperty -Path “HKLM:\SOFTWARE\Wow6432Node\Microsoft\Microsoft Power Query for Excel” -Name “DisableUpdateNotification” -PropertyType DWORD -Value 1
Quick Post: Restart a service on a remote computer using PowerShell
Get-Service -Name w32time -ComputerName Server1 | Set-Service -Status Stopped
Get-Service -Name w32time -ComputerName Server1 | Set-Service -Status Running
Quick Post: Get Login Script for Users
Get-ADUser -Filter * -SearchBase “DC=domainname,DC=com” -properties ScriptPath | select Name,ScriptPath
Quick Post: Count users in an OU structure in AD
Get-ADUser -Filter * -SearchBase “OU=Users,OU=Company,DC=domain,DC=com” | Measure
You’ll get something like this.
Count : 377
Average :
Sum :
Maximum :
Minimum :
Property :
Quick Post: Get a user’s group membership via PowerShell
Get-ADPrincipalGroupMembership -Identity USERNAME | select name
or
Get-ADUser -Identity USERNAME -Properties MemberOf | Select -ExpandProperty MemberOf
Error Deactivating DHCP Scope
On Windows Server 2008 R2 when using netsh to deactivate a DHCP scope you get an error that says, “The command needs a valid Scope IP Address”.
Try again using an elevated PowerShell prompt.
See which distribution list has a specific alias
In this example, find any distribution group that has the word contact in an alias.
Get-DistributionGroup | where {$_.EmailAddresses -match "contact"} | select Name, EmailAddresses | fl