NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

# parameters to set
$connectorName = "Test Powershell Pipeling"
$connectorUuid = "7452729f-0007-49b6-94f7-ca6100c9b8cb"
$api_url = "https://testing-pam-01.caveris.co.uk:9443/pcam/collectors/external/7452729f-0007-49b6-94f7-ca6100c9b8cb"
$access_token = "8dbf3736-1649-497c-b367-170e926507b4"
$hours_interval = 24
$minutes_delay = 0
$seconds_delay = 10

# connector script to use e.g. c:UsersAdministratorpamConnector.ps1
$connectorScript = "$HOMEpamConnector.ps1"

$connectorScript_base64='PCMgV09SS0FST1VORA0KICMgQWRkZWQgdGhlIG5leHQgc2VjdGlvbiBvZiBjb2RlIHRvIGF2b2lkIHRoZSBlcnJvcjogDQogIyAgICAiVGhlIHVuZGVybHlpbmcgY29ubmVjdGlvbiB3YXMgY2xvc2VkOiBDb3VsZCBub3QgZXN0YWJsaXNoIHRydXN0IHJlbGF0aW9uc2hpcCBmb3IgdGhlIFNTTC9UTFMgc2VjdXJlIGNoYW5uZWwuIi4gDQogIz4NCmFkZC10eXBlIEAiDQogICAgdXNpbmcgU3lzdGVtLk5ldDsNCiAgICB1c2luZyBTeXN0ZW0uU2VjdXJpdHkuQ3J5cHRvZ3JhcGh5Llg1MDlDZXJ0aWZpY2F0ZXM7DQogICAgcHVibGljIGNsYXNzIFRydXN0QWxsQ2VydHNQb2xpY3kgOiBJQ2VydGlmaWNhdGVQb2xpY3kgew0KICAgICAgICBwdWJsaWMgYm9vbCBDaGVja1ZhbGlkYXRpb25SZXN1bHQoDQogICAgICAgICAgICBTZXJ2aWNlUG9pbnQgc3J2UG9pbnQsIFg1MDlDZXJ0aWZpY2F0ZSBjZXJ0aWZpY2F0ZSwNCiAgICAgICAgICAgIFdlYlJlcXVlc3QgcmVxdWVzdCwgaW50IGNlcnRpZmljYXRlUHJvYmxlbSkgew0KICAgICAgICAgICAgcmV0dXJuIHRydWU7DQogICAgICAgIH0NCiAgICB9DQoiQA0KW1N5c3RlbS5OZXQuU2VydmljZVBvaW50TWFuYWdlcl06OkNlcnRpZmljYXRlUG9saWN5ID0gTmV3LU9iamVjdCBUcnVzdEFsbENlcnRzUG9saWN5DQo8IyBFTkQgV09SS0FST1VORCAjPgoKPCMKIEdFVCBPUFRTCiAjPgogJGFwaV91cmwgPSAkYXJnc1swXQogJGFjY2Vzc190b2tlbiA9ICRhcmdzWzFdCgogPCMKIENBTEwgQVBJCiAjPgogJGJvZHkgPSAnJwoKIGZvcmVhY2ggKCRpIGluICRpbnB1dCkgewogICAgJGJvZHkgPSAkYm9keSArICRpICsgImBuIgogfQoKCiAkaGVhZGVycyA9IE5ldy1PYmplY3QgIlN5c3RlbS5Db2xsZWN0aW9ucy5HZW5lcmljLkRpY3Rpb25hcnlbW1N0cmluZ10sW1N0cmluZ11dIgogJGhlYWRlcnMuQWRkKCJDb250ZW50LVR5cGUiLCAnYXBwbGljYXRpb24vdGV4dCcpCiAkaGVhZGVycy5BZGQoIlgtQVBJLUtFWSIsICIkYWNjZXNzX3Rva2VuIikKCiB0cnkgewogICAgJHJlc3BvbnNlID0gSW52b2tlLVJlc3RNZXRob2QgLU1ldGhvZCAnUG9zdCcgLVVyaSAkYXBpX3VybCAtQm9keSAkYm9keSAtSGVhZGVycyAkaGVhZGVycwogICAgV3JpdGUtSG9zdCAkcmVzcG9uc2UKIH0gY2F0Y2ggW1N5c3RlbS5OZXQuV2ViRXhjZXB0aW9uXSB7CiAgICBXcml0ZS1Ib3N0ICJFUlJPUjogRmFpbGVkIGNhbGxpbmcgYXBpIgogICAgV3JpdGUtSG9zdCAkXwogICAgZXhpdCAwCiB9CgogV3JpdGUtSG9zdCAiQVBJIENhbGxlZCIK'

$connectorScriptContent = [System.Convert]::FromBase64String($connectorScript_base64)
Set-Content -Path $connectorScript -Value $connectorScriptContent -Encoding Byte

# placeholder data source script to use c:UsersAdministratorconnector-dummy-data-source.ps1
$dataSourceScript = "$HOMEconnector-" + $connectorUuid + "-dummy-data-source.ps1"

$dataSourceScriptContent = @'
#
# This is a placeholder script
#
# You should ammend it so that it outputs entity or object attributes - one per line in the format
# '<attribute_name> : <attribute_value>'
#
# If there is more than one object, then a blank line should be inserted as a separator
# after the last attribute of the first and subsequent objects.
#
'@

@"

Creating a dummy data source placeholder script to add to the task scheduler: $dataSourceScript

"@
Set-Content -Path $dataSourceScript -Value $dataSourceScriptContent

$system_name = $env:computername

$match_result = $api_url -match '^.*//([^.]*).'
$api_short_server = $matches[1]

# The name of your scheduled task.
$taskName = "$connectorName for $system_name to $api_short_server"

$taskActionArgument = "-ExecutionPolicy Unrestricted -WindowStyle Hidden -Command `"& { $dataSourceScript | powershell `'`$input | C:UsersAdministratorpamConnector.ps1 $api_url $access_token`'}`""

# Create a new task action
$taskAction = New-ScheduledTaskAction `
-Execute 'powershell.exe' `
-Argument "$taskActionArgument"

# Create a new base trigger (Daily at NOW + X seconds + Y minutes delay)

$start_time = [DateTime]::Now.AddMinutes($minutes_delay)
$start_time = $start_time.AddSeconds($seconds_delay)
$hourMinute = $start_time.ToString("HH:mm:ss")

# 'Define Task Trigger'
$taskTrigger = New-ScheduledTaskTrigger -Daily -At "$hourMinute"

# create a temp secondary trigger with the required repetition
$start_time = [DateTime]::Now.AddMinutes(60)
$hourMinute = $start_time.ToString("HH:mm")

# 'Define Repetition Trigger'
$repetition_trigger = New-ScheduledTaskTrigger -Once -At "$hourMinute" -RepetitionInterval (New-TimeSpan -Hours $hours_interval) -RepetitionDuration (New-TimeSpan -Hours 23 -Minutes 55)

# Take repetition object from secondary, and insert it into base trigger:
if (($hours_interval -ne 0) -and ($hours_interval -ne 24)) {
$taskTrigger.Repetition = $repetition_trigger.Repetition
}

# Register the scheduled task
Register-ScheduledTask `
-TaskName $taskName `
-Action $taskAction `
-Trigger $taskTrigger `
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.