Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Ignore-SelfSignedCerts
- {
- try
- {
- # Write-Host "Adding TrustAllCertsPolicy type." -ForegroundColor White
- Add-Type -TypeDefinition @"
- using System.Net;
- using System.Security.Cryptography.X509Certificates;
- public class TrustAllCertsPolicy : ICertificatePolicy
- {
- public bool CheckValidationResult(
- ServicePoint srvPoint, X509Certificate certificate,
- WebRequest request, int certificateProblem)
- {
- return true;
- }
- }
- "@
- # Write-Host "TrustAllCertsPolicy type added." -ForegroundColor White
- }
- catch
- {
- Write-Host $_ -ForegroundColor "Yellow"
- }
- [System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
- }
- Ignore-SelfSignedCerts
- [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
- $Global:TM1Session = New-Object Microsoft.PowerShell.Commands.WebRequestSession
- $TM1RestUrl = 'http://'+$TM1Adminhost+':5895/api/v1/Servers'
- $httpPort = $(Invoke-RestMethod -Method Get -uri $TM1RestUrl).value | where {$_.Name -eq $TM1Server} | Select HTTPPORTNumber
- $TM1RestUrl = 'https://'+$TM1Adminhost+':' + $httpPort.HTTPPORTNumber + '/api/v1/'
- $headers = @{"Authorization" = 'Basic ' + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("$($TM1UserID):$($TM1UserPassword)"));}
- $TM1ThreadsUrl = $TM1RestUrl + 'Threads'
- $response = Invoke-RestMethod -Method Get -uri $TM1ThreadsUrl -Headers $headers -WebSession $TM1Session
- $Threads = $response.value
- 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"
- foreach( $Thread in $Threads) {
- 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
- }
- # Logout TM1 Server
- $TM1LogoutUrl = $TM1RestUrl.Substring(0,$TM1RestUrl.Length-3) + 'logout'
- Invoke-RestMethod -Method Get -uri $TM1LogoutUrl -WebSession $TM1Session
- $Threads | Out-GridView
Add Comment
Please, Sign In to add comment