UpdateDeviceLegalHoldState
This is a sample PowerShell script for UpdateDeviceLegalHoldState. You may need to modify it to fit your needs and environment.
Copy
function UpdateLegalHoldState {
param(
[Parameter(Mandatory=$true)] $UserName # Dashboard username
,$Password # Dashboard password. Will prompt if blank or "*"
,[Parameter(Mandatory=$true)] $DashboardUrl # Dashboard URL. Example: https://vault.example.com/Dashboard
,[Parameter(Mandatory=$true)] [Guid] $DeviceId # Device ID to change legal hold status
,[Parameter(Mandatory=$true)] [bool] $EnableLegalHold # Set or unset device on legal hold
,[string] $AuditComments = $null # Comments for audit log
,[string] $LegalHoldComments = $null # Comments to set on legal hold status reason
)
if (!$Password -or ($Password -eq "*")) {
$Password = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR((read-host -assecurestring -Prompt "Enter the password for $UserName")))
}
# Load the WSDL into proxy object
Write-Host "Loading the web service definition..."
$proxy = New-WebServiceProxy -Uri "$DashboardUrl/DashboardService.v.1.0.svc?WSDL" -Namespace "DashboardServiceReference" -Class "foo"
#Create the web service reference
[DashboardServiceReference.UpdateDeviceLegalHoldStateResult] $result = $null
[DashboardServiceReference.UpdateDeviceLegalHoldStateInput] $in = New-Object DashboardServiceReference.UpdateDeviceLegalHoldStateInput
[DashboardServiceReference.CallingContext] $callingContext = New-Object DashboardServiceReference.CallingContext
#Set up calling credentials
$callingContext.ContextIdentity = $Username
$callingContext.AuthenticationToken = $Password
$callingContext.TokenType = [DashboardServiceReference.AuthenticationTokenType]::Password
$callingContext.TokenTypeSpecified = "true"
#Assign Job Parameters
$in.DeviceId = $DeviceId
$in.EnableLegalHold = $true
$in.AuditComment = $AuditComments
$in.LegalHoldComment = $LegalHoldComments
#Now call the web service
Write-Host "Submitting request to update legal hold status job..."
[DashboardServiceReference.ServiceResponse] $serviceResponse = $proxy.UpdateDeviceLegalHoldState($callingContext, $in, [ref] $result)
#Deal with the response
[string] $title = "Error"
[string] $message = ""
if ($serviceResponse) {
switch ($serviceResponse.Status)
{
"Completed" {
if ($result.OverallStatus -eq [DashboardServiceReference.OverallStatus]::Success)
{
$message = "Job submitted"
$title = "Success"
}
else
{
$message = "Call completed but job was not submitted." + $result.Information
}
break
}
"InvalidCredentials" {
$message = $serviceResponse.Information
break
}
"InvalidInput" {
#Deal with this
$message = $serviceResponse.Information
break
}
default {
$message = $serviceResponse.Information + ". Response: " + $serviceResponse.Status.ToString()
}
}
Write-Output "$title`: $message`r`n$($result.Information)"
}
else {
Write-Output "Error: `$serviceResponse is null."
}
}