Difference between revisions of "Windows Server Powershell Commands"
Line 1: | Line 1: | ||
[[Category:Windows]] | [[Category:Windows]] | ||
+ | Windows Storage Manager shows all mgmt options greyed out | ||
+ | Update-StorageProviderCache | ||
Query AD for a list of computers | Query AD for a list of computers | ||
Get-ADComputer -Filter 'operatingSystem -like "*Windows 7*"' -Properties * | Select -Property Name,IPv4Address,OperatingSystem,OperatingSystemVersion | Get-ADComputer -Filter 'operatingSystem -like "*Windows 7*"' -Properties * | Select -Property Name,IPv4Address,OperatingSystem,OperatingSystemVersion |
Revision as of 12:51, 30 June 2019
Windows Storage Manager shows all mgmt options greyed out
Update-StorageProviderCache
Query AD for a list of computers
Get-ADComputer -Filter 'operatingSystem -like "*Windows 7*"' -Properties * | Select -Property Name,IPv4Address,OperatingSystem,OperatingSystemVersion Get-ADComputer -Filter 'operatingSystem -like "*Windows 10*"' -Properties * | Select -Property Name,IPv4Address,OperatingSystem,OperatingSystemVersion Get-ADComputer -Filter 'operatingSystem -like "*Windows Server*"' -Properties * | Select -Property Name,IPv4Address,operatingSystem,OperatingSystemVersion Get-ADComputer -Filter 'Name -like "*CV*"' -Properties * | Select -Property Name,IPv4Address,operatingSystem,OperatingSystemVersion
After removing a node from a DAG, sometimes the cluster objects are still hanging around in server manager even though they are already decommissioned or deleted
cluster node SERVERNAME /forcecleanup
Remove a computer from the domain:
Remove-Computer Remove-Computer -ComputerName
Set the timezone on a server:
Set-TimeZone -Name "Central Standard Time"
Example of setting my iSCSI interface addresses via powershell
New-NetIPAddress -InterfaceAlias NIC3 -IPAddress 172.16.32.11 -PrefixLength 24 New-NetIPAddress -InterfaceAlias NIC4 -IPAddress 172.16.33.11 -PrefixLength 24
Setting DNS address for interface
Set-DnsClientServerAddress -InterfaceAlias Ethernet -ServerAddresses "IPADDRESS1","IPADDRESS2"
Disable/Enable Windows Firewall
Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled True
Create new Network Team
Get-NetAdapter New-NetLBFOTeam Team0 NIC1, NIC2
Installing Dell Openmanage on Windows Server Core
msiexec /i SysMgmt.msi netsh advfirewall firewall add rule name="Dell OpenManage Server Administrator Web GUI" dir=in action=allow protocol=TCP localport=1311 or with powershell New-NetFirewallRule -Name Dell_OMSA -DisplayName "Dell OMSA" -Description "Dell OMSA Web Management" -Protocol TCP -Enabled True -Profile Any -Action Allow -LocalPort 1311
Relocating Domain FSMO Roles
Move-ADDirectoryServerOperationMasterRole -Identity SERVERNAME -OperationMasterRole 0,1,2,3,4
Verify the current WSUS Updates source for the client
REG QUERY "HKLM\Software\Policies\Microsoft\Windows\WindowsUpdate"
Removing a computer object from the AD
Remove-ADComputer -Identity "ComputerName"
Deleting partitions that appear to be undeletable
diskpart list disk select disk n list partition select partition n delete partition override exit
Find out about shutdown events:
Get-EventLog System | Where-Object {$_.EventID -eq "1074" -or $_.EventID -eq "6008" -or $_.EventID -eq "1076"} | ft Machinename, TimeWritten, UserName, EventID, Message -AutoSize -Wrap
Running Windows Backup:
wbadmin start backup -backuptarget:D: -include:C: -allcritical -quiet wbadmin get versions
Equivalent of 'grep'ing in Unix:
netstat -p TCP | Select-String -Pattern 3389
Joining a domain:
Add-Computer -Credential corp\administrator -DomainName corp.domain.com Add-Computer -Credential corp\administrator -DomainName corp.domain.com -OUPath 'ou=Desktops,dc=corp,dc=domain,dc=com' Add-Computer -Credential corp\administrator -DomainName corp.domain.com -OUPath 'ou=Servers,dc=corp,dc=domain,dc=com' -NewName ServerName
List all Possible windows features
Get-WindowsFeature
Installing SNMP: (and it will also install SNMP-Service too)
Install-WindowsFeature SNMP-WMI-Provider
Installing Windows Backup Service
Install-WindowsFeature Windows-Server-Backups Install-WindowsFeature SNMP-WMI-Provider, Windows-Server-Backup
Installing .net 3.5 (mount the Server 2012 DVD first)
Install-WindowsFeature –name NET-Framework-Core –source D:\sources\sxs
Preparing for MS Exchange Server 2013
Install-WindowsFeature Server-Media-Foundation, Web-Dyn-Compression, Web-WMI, Web-Client-Auth, Web-Http-Redirect, Web-Http-Tracing, Web-Request-Monitor,
Preparing for MS Systems Center 2012 (mount the Server 2012 DVD first)
Install-WindowsFeature SNMP-WMI-Provider, Windows-Server-Backup, Web-Server, Web-Metabase, Web-ASP, Web-Windows-Auth, Web-Static-Content, Web-Default-Doc, Web-Digest-Auth, Web-Dir-Browsing, Web-Http-Errors, Web-Http-Logging, Web-Request-Monitor, Web-Filtering, Web-Stat-Compression, Web-Mgmt-Console, Web-Asp-Net45, Web-CGI, Web-ISAPI-Ext, NET-WCF-HTTP-Activation45, Web-Asp-Net -source E:\sources\sxs
Windows Update Client check in to WSUS server
wuauclt /detectnow
Windows Update Client has not checked into server in a long time but client is online
wuauclt /resetauthorization /detectnow
Verify WSUS client Settings:
REG QUERY "HKLM\Software\Policies\Microsoft\Windows\WindowsUpdate"
Extending a file system, such as after you extend the disk within VMware and you want to avoid logging onto the system to finish the file system extend
"rescan" | diskpart $MaxSize = (Get-PartitionSupportedSize -DriveLetter d).sizeMax Resize-Partition -DriveLetter d -Size $MaxSize
Shrinking a file system might give an error about not enough disk space, so defrag it first:
defrag -c -w -v
Below are deprecated versions of commands:
Print out all available features:
PS C:\Windows\system32> dism.exe /online /get-features
Install Windows Backup Service:
PS C:\Windows\system32> dism.exe /online /enable-feature /featurename:WindowsServerBackup
Install .net 3.5. There is sometimes an error dectecting the source files, so we specify the CD sources instead.
PS C:\Windows\system32> dism.exe /online /enable-feature /all /featurename:NetFX3 /Source:D:\sources\sxs