Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <#
- .SYNOPSIS
- ExecWebJob
- .DESCRIPTION
- .parameter $CredInfo
- Credential Name
- .parameter $UriInfo
- webjob's URL
- .EXAMPLE
- ExecWebjob -CredInfo "hoge" -UriInfo "hoge"
- .NOTES
- AUTHOR: wantashi
- LASTEDIT: 2017/08/15
- #>
- param(
- [parameter(Mandatory=$True)]
- [string] $CredInfo,
- [parameter(Mandatory=$True)]
- [string] $Uri
- )
- # GetUri
- #$uri = Get-AutomationVariable -Name $UriInfo
- # GetCredential
- $myCredential = Get-AutomationPSCredential -Name $CredInfo
- # build String of Basic Authentication
- $user = $myCredential.UserName
- $pass = $myCredential.GetNetworkCredential().Password
- $pair = "${user}:${pass}"
- $base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(($pair)))
- $header = @{ Authorization=("Basic {0}" -f $base64AuthInfo) }
- # Exec webjob
- Invoke-RestMethod -Method post -Uri $Uri -ContentType "application/json" -Headers $header
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement