Tag: Powershell-5.1

  • Correctly Setting the PowerShell Root

    Correctly Setting the PowerShell Root

    ⭐ You should NOT set $root or $PSScriptRoot in your profile Your profile runs in contexts where: If you set a $root variable in your profile, you would be lying to your scripts about where they live. ❌ Example of what goes wrong If your profile sets: Then you run a script from: Your script…

  • Scheduled Local Admin

    Scheduled Local Admin

    You could also change the duration to hours with (Get-Date).AddHours($durationInHours)

  • PowerShell Module Bloat

    PowerShell Module Bloat

    #PLEASE GOD, Microsoft, USE STANDARDS in your PowerShell module development ..

  • Upgrade to PWSH Without Being Destructive (even for DCs)

    Upgrade to PWSH Without Being Destructive (even for DCs)

  • Upgrade Windows 11 at Home

    Upgrade Windows 11 at Home

  • Enable AD RDC Rules on Domain Controllers

    Enable AD RDC Rules on Domain Controllers

  • GPOs: List-GPOs-EnabledandLinked-AndBackup

    GPOs: List-GPOs-EnabledandLinked-AndBackup

    How to backup the Group Policies you are actually using

  • Check-WinEvents-Prompted.ps1

    Check-WinEvents-Prompted.ps1

    ‘Check-WinEvents-Prompted.ps1’ #************************************************************************************************************* # Script Name : Get-Latest-WinEvent-Prompted-DCs # Purpose : Check Latest Event log for DCs chosen # Date : #.\Get-UpdateDate.ps13:32 PM 3/13/2024 # – Initial version # Date : #.\Get-UpdateDate.ps11:12 PM 3/14/20244 # – Updated to reflect specific events, added credentials, added prompts # Author : Patrick Burwell #************************************************************************************************************* #Set location first set-location D:\PowerShell…

  • Check-Uptime-DC-Prompt.ps1

    Check-Uptime-DC-Prompt.ps1

    Sometimes a simple script makes life easier…

  • FRS to DFSR Migration Can Be Reset!

    FRS to DFSR Migration Can Be Reset!

    The FRS migration to DFSR can be restarted, even after Eliminiated state… The simple steps to get back is to reset the DFSR Global Settings value from 48 to 0 using ADSIEdit: You then delete the entire “Migrating Sysvols” key on the DFSR services registry: Then, once every RWDC in the domain or forest isn…

  • Get-Pagefile

    Quickly get the remote pagefile of a window server

  • Log Specific IPV4 Traffic When Found

    Log Specific IPV4 Traffic When Found

  • Check for GPO or run GPupdate Remotely

    Check for GPO or run GPupdate Remotely

    This script does lots of things that are handy when group policy (SysVol) replication is a problem… (like an environment still using FRS) My Thanks to Microsoft’s CoPilot for the help in sorting the logic of the try-else-catch commands…

  • Reverse Ping a 255.255.254 Scope

    Reverse Ping a 255.255.254 Scope

    To quickly obtain the devices using an IPv4Address in a scope reverse ping the scope in PowerShell (5.1) ‘#’ReverseLookup-Ipv4Address-By23Range.ps1’$subnet = read-host -Prompt “What IP scope with /23 range? -leave off the last octet numbers – like this 10.228.30. “for ($i=0; $i -le 511; $i++) { $ip = $subnet + $i Resolve-DnsName -name $ip -ea SilentlyContinue|select…

  • Find and Install SSH Module

    Find and Install SSH Module

    $Module = (FIND-Module SSH).name Install-Module -Name $Module -AllowClobber -Verbose -SkipPublisherCheck -Repository PSGallery -AcceptLicense -PassThru|` Import-Module -NoClobber -DisableNameChecking -PassThru -Verbose|Update-Module -Verbose -AcceptLicense -PassThru|Get-Module

  • Remove Revoked Certificates

    Remove Revoked Certificates

    The removal of revoked certificates is not automatic…

  • Set PS 5.1 to use PS 7 PSModulePath

    Set PS 5.1 to use PS 7 PSModulePath

    …might as well prepare by using the D:\PowerShell path now with PS 5.1…

  • Set PowerShell Credential

    Set PowerShell Credential

    …you can make the script prompt you for you admin credential or you can type it in manually, or adjust from your username for more elevation

  • Update ADSS Subnets

    Update ADSS Subnets

    The real advantage of this script is the ability it gives you to update your ADSS subnets quickly #Import the Active Directory moduleImport-Module ActiveDirectory -NoClobber -DisableNameChecking -Scope Local#Import the CSV with headers$csvData = Import-Csv -Path D:\powershell\input\subnets.csv#Checks for any count and breaks if not $nullif(!($csvData.Count)){break}#Loop through each row in the CSVforeach ($row in $csvData) {#Get the…

  • Update-Windows_Powershell.ps1

    Update-Windows_Powershell.ps1

    Updates Windows powershell modules, installs any not installed, and updates help for them all

  • Get ALL A User’s Groups

    Get ALL A User’s Groups

    …get every group a user is in, including the Primary

  • Get Domain Users

    Get Domain Users

    The reason you cannot enumerate all ‘Domain Users’ members is due to size restrictions of the PowerShell commands,

  • VM PS Templates: Query VMs PoweredOn

    VM PS Templates: Query VMs PoweredOn

    This script renumerates through all the VCSAs and makes a big list of the PoweredOn VMs and runs a job against them, like TC (ping)

  • Get-ADGroup WildCard is BROKEN

    Get-ADGroup WildCard is BROKEN

    In the past (2018) you could use ‘like’ on Get-adgroup, like this:

  • PS Script to Promote 2019 Server to RWDC

    PS Script to Promote 2019 Server to RWDC

    Add-WindowsFeature -Name “AD-Domain-Services” -IncludeManagementTools:$False -Confirm -ea Inquire -LogPath “C:\Users\$env:username\Documents\WindowsPowerShell\log\$day-RWDCPromo.log”

  • Set-MpPreference

    Set-MpPreference

    As you can see, Microsoft’s syntax is wrong:They show the syntax for setting soft-passive mode as ‘Set-MpPreference -DisableRealtimeMonitoring $true’ when it is ‘Set-MpPreference -DisableRealtimeMonitoring:$true’ <– NOTE THE COLON??? Arrrrgghhhh! I cannot tell you how frustrating it is when code is not written to give you ANY response unless you get the syntax EXACTLY right. *SIGH*…

  • Gpupdate Latency Errors Lookup Script

    Gpupdate Latency Errors Lookup Script

    I cannot TELL you how hard this was to write. Holy smokes the help on this is terrible.

  • Locate Pervasive Lockouts of AD Accounts

    Locate Pervasive Lockouts of AD Accounts

    You can use PowerShell to search the Security event log for lockout events…

  • PowerShell: Install ActiveDirectory Easily

    PowerShell: Install ActiveDirectory Easily

    I have found this make installing the ActiveDirectory Module FAR easier.Quick.Painless.

  • ChatGPT-AzureAI:Tail in Windows

    ChatGPT-AzureAI:Tail in Windows

    To use this function, simply call it with the path to the file you want to tail and the number of lines you want to show: tail “C:\Path\To\File.txt” 10