Public/Start-AutotaskSession.ps1
<#
.Synopsis .DESCRIPTION .EXAMPLE Example of how to use this cmdlet .EXAMPLE Another example of how to use this cmdlet .INPUTS Inputs to this cmdlet (if any) .OUTPUTS Output from this cmdlet (if any) .NOTES General notes .COMPONENT The component this cmdlet belongs to .ROLE The role this cmdlet belongs to .FUNCTIONALITY The functionality that best describes this cmdlet #> function Start-AutotaskSession { # Sørger for nødvendige credentials ved initialisering $initusername = "ATWSuser.txt" $initpassword = "ATWSpassword.txt" if(Test-Path -Path "C:\OCHAutomationSecureStrings\ATWS.txt"){ $ATWSpwd = Get-Content "C:\OCHAutomationSecureStrings\ATWS.txt" $ATWSsecurePwd = $ATWSpwd | ConvertTo-SecureString $ATWSCred = New-Object System.Management.Automation.PSCredential -ArgumentList $ATWSuser, $ATWSsecurePwd } # end if else{ $ATWSuser = Get-Content "C:OCHAutomationScripts\$initusername" $ATWSpwd = Get-Content "C:OCHAutomationScripts\$initpassword" $ATWSsecurePwd = ConvertTo-SecureString $ATWSpwd -AsPlainText -Force Set-Content "C:\OCHAutomationSecureStrings\ATWS.txt" $ATWSsecurePwd $ATWSCred = New-Object System.Management.Automation.PSCredential -ArgumentList $ATWSuser, $ATWSsecurePwd Remove-Item "$PSScriptRoot\$initusername","$PSScriptRoot\$initpassword" } #end else # Kopler til Autotask API Connect-AutotaskWebAPI -Credential $ATWSCred -RefreshCache # End Region Authentication } |