Tag: PWSH
-

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
You could also change the duration to hours with (Get-Date).AddHours($durationInHours)
-

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

Remote PWSH Session with PSEXEC64
You have installed PWSH (PS7) and have the path. You try to ‘enter-pssession’ and that’s when discover a remote session with PWSH shell will not work without being set native on the server operating system. But you can always use a remote PWSH session using PSEXEC64.
-

PWSH: Get-Latest-WinEvent-Prompted-DCs
This is a VERY useful script that prompts for RWDC or RODCs, prompt to specify EventIDs or just get the last event on each DC, and refactored with Microsoft CoPilot 4 for locations where WinRM is disabled, using Invoke-Command (Enter-PSSession)
-

4sysops.com: how to change the PowerShell prompt (Mirror)

