Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- param($computername = "", $username = "", $password = '')
- # Generate credentials object for authentication
- $SecPasswd = ConvertTo-SecureString $password -AsPlainText -Force
- $Credentials = New-Object System.Management.Automation.PSCredential ([string]::Format("{0}",$username), $secpasswd)
- Invoke-Command -ComputerName $computername -Credential $Credentials -ScriptBlock {
- $wiresharkPath = "C:\Program Files (x86)\Wireshark\dumpcap.exe"
- $wiresharkParameters = @() # if using multiple parameters, enter them like this: @("parameter1","parameter2")
- function This-LogMessage([string]$type,$message)
- { [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 }
- This-LogMessage -type warning -message "RDP delay is increasing, starting wireshark log"
- try { Start-Process -FilePath $wiresharkPath -ArgumentList $wiresharkParameters }
- catch { $ErrorMessage = $_.Exception.Message; This-LogMessage -type error -message "There was an exception: $($ErrorMessage)" }
- finally { This-LogMessage -type done -message "All done. Exiting..." }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement