Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

For prerequisites, refer to Deploying the Survivable Branch Appliance and Using Powershell 3 to Access REST.

...

Code Block
### Re-initialize the ASM with the correct ASM Image
function SearchImageDirectoryName {
    Param($MyLyncVersion, $MyNodeUrl, $MyPs)
    $url = "https://$MyNodeUrl/rest/asmfactoryimage"
    $ImageCmd = Invoke-RestMethod -Uri $url -Method GET  -WebSession $MyPs
    if ((BasicHandler $ImageCmd) -ne 1) {
        write-host "Failed on SearchImageDirectoryName: "(BasicHandler $ImageCmd)
        return 0
    }
    [xml]$ImageCmdXml= $ImageCmd.Substring(5)
    foreach ($image in $ImageCmdXml.root.asmfactoryimage_list.asmfactoryimage_pk.href) {
        $url = $image
        $ImageDetail = Invoke-RestMethod -Uri $url -Method GET -WebSession $MyPs
        [xml]$ImageDetailXml= $ImageDetail.Substring(5)
        if($ImageDetailXml.root.asmfactoryimage.Description.contains($MyLyncVersion)) { return $ImageDetailXml.root.asmfactoryimage.ImageDirectoryName}
    }
    return 0
}
Code Block
### Return the result of the request
Function BasicHandler {
    Param($MyResult)
Code Block


[xml]$XmlResult = $MyResult.Substring(5)
    if($XmlResult.root.status.http_code.contains("200")) {
        return 1
    } else {
        return "Error Code:<"+$XmlResult.root.status.app_status.app_status_entry.code+"> Param:<"+$XmlResult.root.status.app_status.app_status_entry.params+">"
    }
}

### Return the result of the request
Function BasicHandlerCurl {
    Param($MyResult)
    $FiltredMyResult = ""
    foreach ($line in $MyResult) {
        if ($line.StartsWith("<")) {
            $FiltredMyResult += $line
        } elseif ($line.StartsWith(" ")) {
            $FiltredMyResult += $line
        }
    }
    [xml]$XmlResult = $FiltredMyResult
    if($XmlResult.root.status.http_code.contains("200")) {
        return 1
    } else {
        return "Error Code:<"+$XmlResult.root.status.app_status.app_status_entry.code+"> Param:<"+$XmlResult.root.status.app_status.app_status_entry.params+">"
    }
}   

...

Code Block
### 3. Configuring the ASM IP Settings
$ActualStep = "3. Configuring the ASM IP Settings"
$BodyValue = "DHCPEnabled=$DHCPEnabled&ipv4Address=$ipv4Address&ipv4Netmask=$ipv4Netmask&ipv4Gateway=$ipv4Gateway&RemoteDesktopEnabled=$RemoteDesktopEnabled&DNSServer1=$DNSServer1&DNSServer2=$DNSServer2&AclEnable=$AclEnable"
$url = "https://$NodeUrl/rest/sbaconfig"
$Result = Invoke-RestMethod -Uri $url -Method POST -Body $BodyValue -WebSession $ps
if ((BasicHandler $Result) -ne 1) {
    write-host $ActualStep" Failed: "(BasicHandler $Result)
    return 0
}
if ((LookCompletionStatus $NodeUrl $ps) -ne 1) {
    write-host $ActualStep" Failed: "(BasicHandler $Result)
    return 0
}
 
### 4. Update SbcComms
 
### 5. Joining the ASM to a Domain
$ActualStep = "5. Joining the ASM to a Domain"
$BodyValue = "hostName=$hostName&domainName=$domainName&userName=$userName&userPassword=$userPassword"
$url = "https://$NodeUrl/rest/sbaconfig?action=joindomain"
$Result = Invoke-RestMethod -Uri $url -Method POST -Body $BodyValue -WebSession $ps
if ((BasicHandler $Result) -ne 1) {
    write-host $ActualStep" Failed: "(BasicHandler $Result)
    return 0
}
Code Block
if ((LookCompletionStatus $NodeUrl $ps) -ne 1) {
    write-host $ActualStep" Failed: "(BasicHandler $Result)
    return 0
}
Code Block
### 6. Deploying the SBA
$ActualStep = "6. Deploying the SBA"
$url = "https://$NodeUrl/rest/sbaconfig?action=deploy"
$Result = Invoke-RestMethod -Uri $url -Method POST -Body "" -WebSession $ps
if ((BasicHandler $Result) -ne 1) {
    write-host $ActualStep" Failed: "(BasicHandler $Result)
    return 0
}
if ((LookCompletionStatus $NodeUrl $ps) -ne 1) {
    write-host $ActualStep" Failed: "(BasicHandler $Result)
    return 0
}
 
$url = "https://$NodeUrl/rest/sbaconfig?action=startreplication"
$Result = Invoke-RestMethod -Uri $url -Method POST -Body "" -WebSession $ps
if ((BasicHandler $Result) -ne 1) {
    write-host $ActualStep" Failed: "(BasicHandler $Result)
    return 0
}
Code Block
if ((LookCompletionStatus $NodeUrl $ps) -ne 1) {
    write-host $ActualStep" Failed: "(BasicHandler $Result)
    return 0
}
 
$url = "https://$NodeUrl/rest/sbaconfig?action=activatewithlync"
$Result = Invoke-RestMethod -Uri $url -Method POST -Body "" -WebSession $ps
if ((BasicHandler $Result) -ne 1) {
    write-host $ActualStep" Failed: "(BasicHandler $Result)
    return 0
}
if ((LookCompletionStatus $NodeUrl $ps) -ne 1) {
    write-host $ActualStep" Failed: "(BasicHandler $Result)
    return 0
}
Code Block
### 7. Generate and Import an SBA Certificate
$ActualStep = "7. Generate and Import an SBA Certificate"
$BodyValue = "CA=$CA&CALogin=$CALogin&CAPassword=$CAPassword&Domain=$Domain&Email=$Email&Organization=$Organization&OU=$OU&City=$City&State=$State&Country=$Country&CsrTemplate=$CsrTemplate&KeySize=$KeySize"
$url = "https://$NodeUrl/rest/sbacsr?action=generatecsr"
$Result = Invoke-RestMethod -Uri $url -Method POST -Body $BodyValue -WebSession $ps
Code Block

if ((BasicHandler $Result) -ne 1) {
    write-host $ActualStep" Failed: "(BasicHandler $Result)
    return 0
}

if ((LookCompletionStatus $NodeUrl $ps) -ne 1) {
    write-host $ActualStep" Failed: "(BasicHandler $Result)
    return 0
}

Code Block
### 8. Starting the SBA Services
$ActualStep = "8. Starting the SBA Services"
$BodyValue = "serviceName=16"
$url = "https://$NodeUrl/rest/sbaconfig?action=enablesvc"
$Result = Invoke-RestMethod -Uri $url -Method POST -Body $BodyValue -WebSession $ps
if ((BasicHandler $Result) -ne 1) {
    write-host $ActualStep" Failed: "(BasicHandler $Result)
    return 0
}
if ((LookCompletionStatus $NodeUrl $ps) -ne 1) {
    write-host $ActualStep" Failed: "(BasicHandler $Result)
    return 0
}
Code Block

### 9. Applying an SBA Security Template
$ActualStep = "9. Applying an SBA Security Template"
$BodyValue = "templateType=0&sbaInstallFilename=0"
$url = "https://$NodeUrl/rest/sbaconfig?action=applysectemplate"
$Result = Invoke-RestMethod -Uri $url -Method POST -Body $BodyValue -WebSession $ps
if ((BasicHandler $Result) -ne 1) {
    write-host $ActualStep" Failed: "(BasicHandler $Result)
    return 0
}
if ((LookCompletionStatus $NodeUrl $ps) -ne 1) {
    write-host $ActualStep" Failed: "(BasicHandler $Result)
    return 0
}
 
### 10. Install the Latest Lync SBA Cumulative Update

...