Video Screencast Help
Symantec Secure Login will be live on Connect starting February 25. Get the details here.

SEPM12.1 RU2 WebServices - Importing a policy example

Created: 29 Nov 2012 • Updated: 02 Jan 2013 | 1 comment
Yoann WYFFELS's picture
+1 1 Vote
Login to vote

Hi everybody,

Here a little "Howto" in PowerShell to import a policy into SEPM 12.1 RU2. No example is attached by default, so here it is:

# Directory where this script is located
$ScriptDir = Split-Path $MyInvocation.MyCommand.Path

# Dot-Source includes from our common library
. $ScriptDir\common\Get-SepmRmmWebService.ps1

function importLUPolicy{

    param([ValidateNotNullOrEmpty()]$configFile = "$($ScriptDir)\Config.xml")
        # Read our config file
        [xml]$config = Get-Content $configFile
        # Generate a client proxy for communicating with the command web service.
        $policyService = Get-SepmRmmWebService -HostName $config.SepmWS.HostIpAddress -Port $config.SepmWS.PortNo -WsdlFile "$($config.SepmWS.wsdlDir)\PolicyService.wsdl" -AccessToken $config.SepmWS.AccessToken
        #Read the policy file
        $bytes = [System.IO.File]::ReadAllBytes("$($ScriptDir)\policy.dat")

        #Import policy
        $policyService.importPolicy("My Imported Policy","","",$bytes)
    catch [System.Web.Services.Protocols.SoapException]
        Write-Error "Unexpected SoapException: $_.Exception.Detail.FirstChild.get_Name() - $_.Exception.Detail.FirstChild.message"
        $error[0].Exception | Format-List -Force
        Write-Error ("Unexpected error")


policy.dat file has to be exported from a SEPM and is located in the same directory than the script himself.

Comments 1 CommentJump to latest comment

Yoann WYFFELS's picture

As a user report, ". $ScriptDir\common\Get-SepmRmmWebService.ps1" isn't included in download.

It's because this script (and many others), are provided by Symantec on the "SEP12 RUx part2 - Tools" download in which you'll find Documentations and PowerShell scripts examples about SEP WebServices.

My script need to be installed into the top directory of PowerShell sample scripts provided by Symantec.

They are located in "Integration\SEPM_WebService_SDK\Sample_Code\PowerShell" in the "SEP12 RUx part2 - Tools" CD.

Don't hesitate to contact me if you have questions about webservices

Login to vote