Difference between revisions of "Powershell"

From Max's Wiki
Jump to navigation Jump to search
Line 24: Line 24:
 
Remote into remote server using PowerShell with the following command:
 
Remote into remote server using PowerShell with the following command:
  
PS C:\> Enter-PSSession -ComputerName dc1
+
PS C:\> Enter-PSSession -ComputerName dc1
[dc1]: PS C:\Users\Administrator\Documents> sl c:\
+
[dc1]: PS C:\Users\Administrator\Documents> sl c:\
  
  
 
Show BIOS Information:
 
Show BIOS Information:
gwmi win32_bios
+
gwmi win32_bios
  
 
Run:
 
Run:
Invoke-Command -ComputerName dc1, dc2 {
+
Invoke-Command -ComputerName dc1, dc2 {
Set-NetFirewallRule -DisplayGroup 'Remote Event Log Management' -Enabled True -PassThru |
+
Set-NetFirewallRule -DisplayGroup 'Remote Event Log Management' -Enabled True -PassThru |
select DisplayName, Enabled
+
select DisplayName, Enabled
} -Credential (Get-Credential)
+
} -Credential (Get-Credential)
 +
 
 +
Remote Execution Policies
 +
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-6#set-a-different-execution-policy-for-one-session

Revision as of 03:56, 10 November 2018


Run Powershell Remotely

How to Run PowerShell Commands on Remote Computers

View Installed Updates Remotely

Get-Hotfix -computername SEA-SRV-01 | Select HotfixID, Description, InstalledOn | Sort-Object InstalledOn

Uninstall Updates:

  • psexec @target+workstations.txt -d -s
  • wusa.exe /uninstall /kb:000000 /quiet /norestart

View Mapped Drives Remotely

Get-WmiObject Win32_MappedLogicalDisk -computer <computername> | select name, providername

Other

Powershell Commands for Hyper-V 2012: http://marckean.wordpress.com/2012/09/26/windows-server-2012-hyper-v-server-command-line-configuration-2/

COM+ Network Access (DCOM-In) mikefrobbins.com/2013/02/28/use-powershell-to-remotely-enable-firewall-exceptions-on-windows-server-2012/


Remote into remote server using PowerShell with the following command:

PS C:\> Enter-PSSession -ComputerName dc1
[dc1]: PS C:\Users\Administrator\Documents> sl c:\


Show BIOS Information:

gwmi win32_bios

Run:

Invoke-Command -ComputerName dc1, dc2 {
Set-NetFirewallRule -DisplayGroup 'Remote Event Log Management' -Enabled True -PassThru |
select DisplayName, Enabled
} -Credential (Get-Credential)

Remote Execution Policies

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-6#set-a-different-execution-policy-for-one-session