-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPowerShell Commands
More file actions
33 lines (18 loc) · 986 Bytes
/
PowerShell Commands
File metadata and controls
33 lines (18 loc) · 986 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Prompt change
function prompt {"PS: $(get-date)>"}
# AD listing requires first
Import-Module ActiveDirectory
# If not available then:
Install-WindowsFeature RSAT-AD-PowerShell
# List all users in AD Group
Get-ADGroupMember -Identity "<AD Group Name>" | Get-ADUser -Property DisplayName | select name,samaccountname
# List all group an user belongs to
Get-ADUser -Identity <samaccountname> -Properties * | Select-Object -ExpandProperty MemberOf
Get-ADPrincipalGroupMembership <samaccountname> | select name
# Elevate before run
# Run MyScript.ps1 with elevated privilege
Start-Process powershell -ArgumentList '-noprofile -file MyScript.ps1' -verb RunAs
# Run command with elevated privilege
Start-Process powershell -ArgumentList '<Command>' -verb RunAs
# Port forward Windows host to WSL2 guest
netsh interface portproxy add v4tov4 listenport=<port#> listenaddress=0.0.0.0 connectport=<port#> connectaddress=<wsl2 guest ip address>