Difference between revisions of "Windows Server Powershell Commands"

From DFWLPiki
Jump to: navigation, search
(Created page with "Category:Windows Running Windows Backup: wbadmin start backup -backuptarget:D: -include:C: -allcritical -quiet wbadmin get versions Equivalent of 'grep'ing in Unix: net...")
 
Line 1: Line 1:
 
[[Category:Windows]]
 
[[Category:Windows]]
 +
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:
 
Running Windows Backup:
 
  wbadmin start backup -backuptarget:D: -include:C: -allcritical -quiet
 
  wbadmin start backup -backuptarget:D: -include:C: -allcritical -quiet

Revision as of 19:41, 4 February 2017

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