Advertisement
Guest User

Untitled

a guest
Sep 13th, 2017
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. param($computername = "", $username = "", $password = '')
  2.  
  3. # Generate credentials object for authentication
  4. $SecPasswd = ConvertTo-SecureString $password -AsPlainText -Force
  5. $Credentials = New-Object System.Management.Automation.PSCredential ([string]::Format("{0}",$username), $secpasswd)
  6.  
  7. Invoke-Command -ComputerName $computername -Credential $Credentials -ScriptBlock {
  8.  
  9. $wiresharkPath = "C:\Program Files (x86)\Wireshark\dumpcap.exe"
  10. $wiresharkParameters = @() # if using multiple parameters, enter them like this: @("parameter1","parameter2")
  11.  
  12. function This-LogMessage([string]$type,$message)
  13. { [string]::Format("[{0}] [{1}] `t{2}{3}", (Get-Date),$type,$message,$Global:blank) | Out-File -FilePath "C:\temp\$(Get-Date -Format 'dd.MM.yyyy')-wireshark.log" -Append }
  14.  
  15.  
  16. This-LogMessage -type warning -message "RDP delay is increasing, starting wireshark log"
  17.  
  18. try { Start-Process -FilePath $wiresharkPath -ArgumentList $wiresharkParameters }
  19. catch { $ErrorMessage = $_.Exception.Message; This-LogMessage -type error -message "There was an exception: $($ErrorMessage)" }
  20. finally { This-LogMessage -type done -message "All done. Exiting..." }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement