Windows administration

cmd HLM\software\policies\microsoft\windows\system -> allowDomainPINLogon"=dword:00000001

  • Exchange PowerShell

powershell Get-mailbox -identity username | fl database

powershell Get-Mailbox -Filter {MailboxMoveBatchName -like "*-FA-*"} | select DisplayName, MailboxMoveBatchName | Format-Table -AutoSize

powershell Get-Mailbox benf@netwealth.com.au | select alias

powershell Get-CASMailbox | where { ($_.ActiveSyncEnabled -eq "True") -or ($_.OWAEnabled -eq "True") } | Select-Object Identity, ActiveSyncEnabled, OWAEnabled, PrimarySMTPAddress | Sort-Object -Property @{Expression = "Identity"; Ascending = $True} | Export-Csv -Path "c:\temp\Audit.csv" -NoTypeInformation

powershell Get-MsolUser -UserPrincipalName $principleuser | Select-Object -ExpandProperty StrongAuthenticationRequirements

  • install .NET Framework 2 & 3

cmd DISM /Online /Enable-Feature /FeatureName:NetFx3 /All /LimitAccess /Source:"\\nw\dfs\archive\Microsoft\Win10-1709\sources\sxs"

  • Active Directory PowerShell

powershell Get-ADUser -Filter {OfficePhone -like '*9657*'} -Properties * | Select Name, telephoneNumber, Department, mail

powershell Get-ADUser -Filter * -Properties telephoneNumber,state | where {($_.telephoneNumber -ne $null) -and ($_.state -eq $null)} | select name, company, mail | Sort-Object -Property @{Expression = "Name"; Ascending = $True}

powershell Get-ADUser -Filter {Title -like 'Training & Relationship Manager'} -Properties * | Select Name, Department, mail | Format-Table -AutoSize

powershell Get-ADUser -Filter {(Company -like "*pathway*") -and (Enabled -ne $False)} -Properties * | where {($_.state -ne $null) -and ($_.mobile -eq $null)} | select name, mail, company, title, telephonenumber, state, mobile | Sort-Object -Property @{Expression = "state"; Ascending = $True} | Format-Table -AutoSize

powershell Get-ADComputer -Filter {(name -notlike '*prod') -and (name -notlike '*acurity*')} -SearchBase"OU=Servers, DC=NW, DC=internal" | select name, DNSHostName

powershell Get-ADUser -Filter {OfficePhone -like '*9655*'} -Properties * | Select Name, telephoneNumber, Department, mail |Sort-Object -Property @{Expression = "Name"; Ascending = $True}

powershell Get-ADUser -Filter {OfficePhone -like '*9655*14*'} -Properties * | Select Name, telephoneNumber, Department, mail | Format-Table -AutoSize

powershell Get-ADGroupMember -identity <AD-GROUP-NAME> -Recursive | Get-ADUser -Property DisplayName | Select Name, ObjectClass,DisplayName | Sort-Object -Property @{Expression = "DisplayName"; Ascending = $True} | Format-Table -AutoSize

  • list logged on users

  • non-RDS hosts

    powershell Get-WmiObject -ComputerName <HOSTNAME> -Class Win32_ComputerSystem | Select-Object UserName

  • RDS hosts

    cmd quser /server <HOSTNAME>

  • install/re-register default Microsoft store apps

powershell Get-AppXPackage | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}

  • list installed programs

powershell Get-WmiObject -Class Win32_Product -ComputerName <HOSTNAME> | where {($_.Name -like "*Microsoft Visio*") -or ($_.Name -like "*Premium*")} | Select Name

  • VMWare PowerCLI

powercli Get-VM | where {$_.PowerState -eq "PoweredOn"} | select name, powerstate, vmhost, memorygb, NumCPU, @{N="IPAddress"; E={$_.Guest.IPAddress[0]}}, @{N="DnsName"; E={$_.ExtensionData.Guest.Hostname}} | Sort-Object -Property @{Expression = "name"; Ascending = $True} | Format-Table -AutoSize

  • IIS export config

cmd %windir%\System32\inetsrv\appcmd.exe list apppool /config /xml > C:\temp\<filename>.xml %windir%\System32\inetsrv\appcmd.exe list site /config /xml > C:\temp\<filename>.xml - change Windows network profile

powershell $NetProfile = Get-NetConnectionProfile -InterfaceAlias Ethernet1 $NetProfile.NetworkCategory = "Private" Set-NetConnectionProfile -InputObject $Profile - pass local variables to remote PoSH session

powershell $localVar = "This is a local variable" Invoke-Command -ComputerName <HOSTNAME> -ScriptBlock { Write-Output The value of variable a is: $using:localVar }