Guest User

Untitled

a guest
Jul 18th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. function Ignore-SelfSignedCerts
  2. {
  3. try
  4. {
  5. # Write-Host "Adding TrustAllCertsPolicy type." -ForegroundColor White
  6. Add-Type -TypeDefinition @"
  7. using System.Net;
  8. using System.Security.Cryptography.X509Certificates;
  9. public class TrustAllCertsPolicy : ICertificatePolicy
  10. {
  11. public bool CheckValidationResult(
  12. ServicePoint srvPoint, X509Certificate certificate,
  13. WebRequest request, int certificateProblem)
  14. {
  15. return true;
  16. }
  17. }
  18. "@
  19.  
  20. # Write-Host "TrustAllCertsPolicy type added." -ForegroundColor White
  21. }
  22. catch
  23. {
  24. Write-Host $_ -ForegroundColor "Yellow"
  25. }
  26.  
  27. [System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
  28. }
  29.  
  30. Ignore-SelfSignedCerts
  31.  
  32. [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
  33.  
  34. $Global:TM1Session = New-Object Microsoft.PowerShell.Commands.WebRequestSession
  35.  
  36. $TM1RestUrl = 'http://'+$TM1Adminhost+':5895/api/v1/Servers'
  37. $httpPort = $(Invoke-RestMethod -Method Get -uri $TM1RestUrl).value | where {$_.Name -eq $TM1Server} | Select HTTPPORTNumber
  38.  
  39. $TM1RestUrl = 'https://'+$TM1Adminhost+':' + $httpPort.HTTPPORTNumber + '/api/v1/'
  40. $headers = @{"Authorization" = 'Basic ' + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("$($TM1UserID):$($TM1UserPassword)"));}
  41. $TM1ThreadsUrl = $TM1RestUrl + 'Threads'
  42.  
  43. $response = Invoke-RestMethod -Method Get -uri $TM1ThreadsUrl -Headers $headers -WebSession $TM1Session
  44. $Threads = $response.value
  45.  
  46. Write-Host "ID`t Name`t Context `t State `t Function `t ObjectType `t ObjectName `t RLocks `t IXLocks `t WLocks `t ElapsedTime `t WaitTime `t Info"
  47.  
  48. foreach( $Thread in $Threads) {
  49. Write-Host $Thread.ID "`t" $Thread.Name "`t" $Thread.Context "`t" $Thread.State "`t" $Thread.Function "`t" $Thread.ObjectType "`t" $Thread.ObjectName "`t" $Thread.RLocks "`t" $Thread.IXLocks "`t" $Thread.WLocks "`t" $Thread.ElapsedTime "`t" $Thread.WaitTime "`t" $Thread.Info
  50. }
  51.  
  52. # Logout TM1 Server
  53. $TM1LogoutUrl = $TM1RestUrl.Substring(0,$TM1RestUrl.Length-3) + 'logout'
  54. Invoke-RestMethod -Method Get -uri $TM1LogoutUrl -WebSession $TM1Session
  55.  
  56. $Threads | Out-GridView
Add Comment
Please, Sign In to add comment