Archive

Posts Tagged ‘PowerShell’

Get-RDPCertificate PowerShell Function

March 18, 2021 Leave a comment

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.

https://github.com/PonchoHobono/Scripts/blob/master/PowerShell/ActiveDirectory/FindGroupManagedBy.ps1

Encoding & Decoding Base64 using PowerShell

November 4, 2018 Leave a comment

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

October 28, 2016 Leave a comment

[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

April 30, 2015 Leave a comment

Get-Service -Name w32time -ComputerName Server1 | Set-Service -Status Stopped
Get-Service -Name w32time -ComputerName Server1 | Set-Service -Status Running

Categories: Computers Tags: ,

Quick Post: Get Login Script for Users

February 12, 2015 Leave a comment

Get-ADUser -Filter * -SearchBase “DC=domainname,DC=com” -properties ScriptPath | select Name,ScriptPath

Quick Post: Count users in an OU structure in AD

February 5, 2015 Leave a comment

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

February 4, 2015 Leave a comment

Get-ADPrincipalGroupMembership -Identity USERNAME | select name

or

Get-ADUser -Identity USERNAME -Properties MemberOf | Select -ExpandProperty MemberOf

Error Deactivating DHCP Scope

October 21, 2014 Leave a comment

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”.

1 Error

Try again using an elevated PowerShell prompt.

2 Working

Categories: Computers Tags: , , ,

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
Categories: Computers Tags: ,