Chris Wahl chriswahl
-
Wahl Network
- Austin, TX
- Sign in to view email
- http://wahlnetwork.com
View Connect-Rubrik.Tests.ps1
# Import | |
Import-Module -Name "$PSScriptRoot\..\Rubrik" -Force | |
. "$(Split-Path -Parent -Path $PSScriptRoot)\Rubrik\Private\Get-RubrikAPIData.ps1" | |
$resources = GetRubrikAPIData -endpoint ('Login') | |
# Pester | |
Describe -Name 'Connect-Rubrik Tests' -Fixture { | |
It -name 'Ensure that Resources are loaded' -test { | |
$resources | Should Not BeNullOrEmpty |
View ErrorLoop2.ps1
function ThrowErrors() | |
{ | |
throw "This is error number $i" | |
} | |
function LoopErrors() | |
{ | |
Process { | |
$i = 0 | |
while ($i -le 10) |
View ErrorLoop1.ps1
function ThrowErrors() | |
{ | |
throw "This is error number $i" | |
} | |
function LoopErrors() | |
{ | |
Process { | |
$i = 0 | |
while ($i -le 10) |
View ConvertFrom-JSON2.ps1
function ParseItem($jsonItem) | |
{ | |
if($jsonItem.PSObject.TypeNames -match 'Array') | |
{ | |
return ParseJsonArray($jsonItem) | |
} | |
elseif($jsonItem.PSObject.TypeNames -match 'Dictionary') | |
{ | |
return ParseJsonObject([HashTable]$jsonItem) | |
} |
View PATCH-Example-Rubrik.ps1
# Required API Variables | |
$uri = 'https://brik1.rubrik.demo:443/vm/0b046b24-3fdb-4b33-b0c8-670fa1e96075-vm-6409' | |
$body = @{ | |
slaDomainId = 'GOLD_aa4c5eee-51d6-4901-aeb4-5ba44f7f65cc' | |
} | |
# RESTful API Call | |
$r = Invoke-WebRequest -Uri $uri -Headers $global:RubrikHead -Method PATCH -Body (ConvertTo-Json -InputObject $body) |
View PUT-Example-NSX.ps1
# Required API Variables | |
$uri = 'https://nsx1.glacier.local:443/api/2.0/vdn/controller/cluster' | |
$body = '<controllerConfig> | |
<sslEnabled>true</sslEnabled> | |
</controllerConfig>' | |
# RESTful API Call | |
$r = Invoke-WebRequest -Uri $uri -Method Post -Body $body -ContentType 'application/xml' |
View POST-Example-Rubrik.ps1
# Required API Variables | |
$uri = 'https://brik1.rubrik.demo:443/job/type/backup' | |
$body = @{ | |
vmId = '0b046b24-3fdb-4b33-b0c8-670fa1e96075-vm-6409' | |
} | |
# RESTful API Call | |
$r = Invoke-WebRequest -Uri $uri -Headers $global:RubrikHead -Method Post -Body (ConvertTo-Json -InputObject $body) |
View Get-RubrikSLA_Lite.ps1
# Build the URI (Universal Resource Identifier), also known as the Resource or Endpoint | |
$server = 'brik1.rubrik.demo' | |
$uri = 'https://'+$server+':443/slaDomain' | |
# Submit the request to the RESTful Resource using the GET method | |
try | |
{ | |
$r = Invoke-WebRequest -Uri $uri -Headers $global:RubrikHead -Method Get | |
$result = ConvertFrom-Json -InputObject $r.Content | |
} |
View New-RubrikMount.ps1
#Requires -Version 3 | |
function New-RubrikMount | |
{ | |
<# | |
.SYNOPSIS | |
Create a new Live Mount from a protected VM | |
.DESCRIPTION | |
The New-RubrikMount cmdlet is used to create a Live Mount (clone) of a protected VM and run it in an existing vSphere environment. | |
.NOTES | |
Written by Chris Wahl for community usage |
View Connect-Rubrik.ps1
#Requires -Version 3 | |
function Connect-Rubrik | |
{ | |
<# | |
.SYNOPSIS | |
Connects to Rubrik and retrieves a token value for authentication | |
.DESCRIPTION | |
The Connect-Rubrik function is used to connect to the Rubrik RESTful API and supply credentials to the /login method. Rubrik then returns a unique token to represent the user's credentials for subsequent calls. Acquire a token before running other Rubrik cmdlets. | |
.NOTES | |
Written by Chris Wahl for community usage |
NewerOlder