👨💻PowerShell
L33T scripts and tools for PowerShell
Get the name of the current user
whoami
Set the local user to an admin (will need to log out then back in to take effect)
net localgroup Administrators whoami_result_here /add
Start a sync from AD to AAD on the sync client server
Start-ADSyncSyncCycle -PolicyType Delta
Force a sync to the DC to update Group Policy
gpupdate/force
Get list of what mailboxes a user has access to and to what level
Connect-ExchangeOnline
$mailbox='<users email>'
$mailboxes=Get-Mailbox -ResultSize Unlimited
foreach($mailbox in $mailboxes){Get-MailboxPermission -Identity $mailbox.Identity -User $mailbox}
Force a password change of a local user (run this as system, new password include quotation marks)
net user username "newPassword"
To remove a computer from a domain (on the computer) replacing Domain_Name\Administrator
with relevant credential
Remove-Computer -UnjoinDomaincredential Domain_Name\Administrator -PassThru -Verbose -Restart -Force
Create a new local user from and then add them to Administrator group, replacing username
and password
net user /add "username" password
net localgroup administrators "username" /add
Get the current WiFi
Netsh WLAN show interfaces
Manually install Microsoft Store
$manifest = (Get-AppxPackage Microsoft.WindowsStore).InstallLocation + ‘AppxManifest.xml’
Get-AppXPackage *WindowsStore* -AllUsers | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
See what calendars a user has access to
Get-Mailbox | % { Get-MailboxFolderPermission (($_.PrimarySmtpAddress.ToString())+”:\Calendar”) -User *user1* -ErrorAction SilentlyContinue} | select Identity,User,AccessRights
Update a user UPN after changing their name in AD
Connect-AzureAD
Set-AzureADUser -ObjectId "olduser@domain.com" -UserPrincipalName "newuser@domain.com"
Last updated