Difference between revisions of "Powershell"

From Max's Wiki
Jump to navigation Jump to search
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
__FORCETOC__
 
__FORCETOC__
 +
 +
==Run Powershell Remotely==
 +
[https://www.howtogeek.com/117192/how-to-run-powershell-commands-on-remote-computers/ How to Run PowerShell Commands on Remote Computers]
 +
 
==View Installed Updates Remotely==
 
==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
 +
 +
==Something==
 +
$LiveCred = Get-Credential
 +
#$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential
 +
$LiveCred -Authentication Basic -AllowRedirection
 +
#Import-PSSession $Session
 +
Get-MailboxFolderPermission -Identity clinicalassessments@kcsarc.org:\Calendar
 +
#Michael does not currently have access to this calendar
 +
#Add-MailboxFolderPermission -Identity clinicalassessments@kcsarc.org:\Calendar -User myu@kcsarc.org -AccessRights Editor
 +
#Get-MailboxFolderPermission -Identity clinicalassessments@kcsarc.org:\Calendar
 +
#Success!
  
Get-Hotfix -computername SEA-SRV-01 | Select HotfixID, Description, InstalledOn | Sort-Object InstalledOn
+
Get-ADUser -Filter {Enabled -eq $True} -SearchBase "OU=Core Users,DC=core,DC=coredesigninc,DC=com" -Properties PasswordLastSet, PasswordNeverExpires | Sort-Object Name | Format-Table Name, PasswordLastSet, PasswordNeverExpires
  
Uninstall Updates
+
==Check for MD5==
psexec @target+workstations.txt -d -s wusa.exe /uninstall /kb:000000 /quiet /norestart
+
Get-FileHash -Path C:\pathhere.exe -Algorithm SHA512 or MD5

Latest revision as of 22:21, 24 July 2019


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

Something

$LiveCred = Get-Credential
#$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential 
$LiveCred -Authentication Basic -AllowRedirection
#Import-PSSession $Session
Get-MailboxFolderPermission -Identity clinicalassessments@kcsarc.org:\Calendar
#Michael does not currently have access to this calendar
#Add-MailboxFolderPermission -Identity clinicalassessments@kcsarc.org:\Calendar -User myu@kcsarc.org -AccessRights Editor
#Get-MailboxFolderPermission -Identity clinicalassessments@kcsarc.org:\Calendar
#Success!
Get-ADUser -Filter {Enabled -eq $True} -SearchBase "OU=Core Users,DC=core,DC=coredesigninc,DC=com" -Properties PasswordLastSet, PasswordNeverExpires | Sort-Object Name | Format-Table Name, PasswordLastSet, PasswordNeverExpires

Check for MD5

Get-FileHash -Path C:\pathhere.exe -Algorithm SHA512 or MD5