PS Schedule script full

## Create the Basic Authentication 
$secpasswd = ConvertTo-SecureString  "<password>"  -AsPlainText -Force
$mycreds = New-Object System.Management.Automation.PSCredential ( "<username>" , $secPasswd)

## Set the PS paramaters
$url = " https://iawebapi.automatedvision.info:8081/Dispatcher/SchedulingService/jobs"
$Parameter_Identitifier = New-Guid
$Parameter_Message = "Testing in progress"

## Configure the Payload/Body (JSON)
$body = '{
"Description":" Send Message API ",
"When": {"Immediate": true,
"IsLocalTime": true,
"UseWakeOnLAN": false},
"What": [{
    "ID":" 0D05A348-4574-4CAB-82F9-A5D3251457FD ",
    "Type": 0,"Name":" Send Message API "
    }],
"Who": [{
    "ID":" 4FF6C7C2-4D63-47F7-AE28-CE8BDA0BA36D ",
    "Type": 0,
    "Name":" SB-IV-AM02 "
    },
    {
    "ID":" 325282B6-2099-4FBB-B60B-38EC4F96E755 ",
    "Type": 0,
    "Name":" SB-IV-AM01 "
    }],
"Parameters": [{
    "Identifier":"'+$Parameter_Identitifier+'",
    "Type": 0,
    "TaskContainerGuid":" 0D05A348-4574-4CAB-82F9-A5D3251457FD ",
    "TaskContainerName":" Send Message API ",
    "JobGuid": "{00000000-0000-0000-0000-000000000000}",
    "JobName": "",
        "JobParameters": [{
            "Name":"Caption",
            "Type":0,
            "Description":"",
            "Value1":"This is a test",
            "Hint":"Please provide the necessary input",
            "Selection":""
            },
            {
            "Name":"Message",
            "Type":0,
            "Description":"",
            "Value1":"'+$Parameter_Message+'",
            "Value2":"",
            "Value3":"",
            "Hint":"Please provide the necessary input",
            "Selection":""
            }]
            }]
            }'

##Execute the webrequest to schedule the task
Invoke-WebRequest -Uri $url -Method Post -Credential $mycreds -ContentType "application/json" -Body $body