Checking the status of active users and disabling them if required.
REST is used to create users
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
#Param must be the first executable line Param( [string] $ContactComment = "Inital Entry", [string] $SystemLoginID = "12345", [string] $IsActive = "0", [string] $Name = "HALL, NICHOLAS A", [string] $DefaultTemplateID = "T1201", [string] $AppliedTemplateID = "T1201", [string] $LinkedTemplateID1 = "T1201", [string] $LinkedTemplateID2 = "T2100303", [string] $UserSubtemplateIDs1 = "T063", [string] $UserSubtemplateIDs2 = "ST5083", [string] $CustomUserDictionaries = "\\\\epic-server\\User_Dictionaries\\12345dictionary.tlx" ) #Remove-Variable * -ErrorAction SilentlyContinue; Remove-Module *; $error.Clear(); Clear-Host #https://vm9008.info.sys/Interconnect-REL-EDI/DeveloperView/Main.aspx?clientid=1 $Request = '{"LinkedTemplatesConfig":{"DefaultTemplateID":{"ID":"' + $DefaultTemplateID + '","Type":"external"},"AppliedTemplateID":{"ID":"' + "$AppliedTemplateID" + '","Type":"external"},"AvailableLinkableTemplates":[{"StartDate":"","EndDate":"","LoginTypes":[],"LinkedTemplateID":{"ID":"' + "$LinkedTemplateID1" + '","Type":"external"}},{"StartDate":"","EndDate":"","LoginTypes":[],"LinkedTemplateID":{"ID":"' + "$LinkedTemplateID2" + '","Type":"external"}}]},"UserSubtemplateIDs":[{"Index":"1","Identifier":{"ID":"' + "$UserSubtemplateIDs1" + '","Type":"external"}},{"Index":"2","Identifier":{"ID":"' + "$UserSubtemplateIDs2" + '","Type":"external"}}],"CustomUserDictionaries":[{"Index":"1","Value":"' + $CustomUserDictionaries + '"}],"LinkedProviderID":{"ID":"","Type":""},"IdentityIDs":[],"ExternalIdentifiers":[{"Identifier":"e12345","IdentifierType":"EMC Mckesson Document Imaging","IsActive":"true"}]}' try { $RestResults = Invoke-RestMethod -Method Put $url -contentType "application/json" -Body $Request foreach($id in $RestResults.UserIDs) { Write-Host $id.ID - $id.Type } if ($RestResults.UserIDs.Count -eq 4) { Write-Host "SUCCESS!" } $RestResults.Messages } catch { if ($_.exception.Response.StatusCode -eq "BadRequest") { #$_.exception.Response.StatusDescription if ($_.exception.Response.StatusDescription -match '^.*System login ID must be unique\.') { Write-Host "Already Exist!" } else { Write-Host "BadRequest: " $_.exception.Response.StatusDescription } } else { $_.Exception | gm $_.Exception | Select-Object -Property * $_.exception.Response.StatusCode } #$_.exception.message #$_.exception.InnerException #$_.Exception.ItemName } |
WSDL is used to Terminate/SoftDelete / Inactivate users
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
Remove-Variable * -ErrorAction SilentlyContinue; Remove-Module *; $error.Clear(); Clear-Host $where = 'https://EpicServer/Interconnect-REL-EDI/wcf/Epic.Security.GeneratedServices/PersonnelManagement.svc' $ws = New-WebServiceProxy -uri $where -UseDefaultCredential $namespace = $ws.getType().namespace foreach($line in get-content "c:\termList.txt") { try { $recipients = $line -split [RegEx]::Escape("|") $samAccountName = $recipients[1].trim() [Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy61rvices_PersonnelManagement_svc.PersonnelManagementViewUserResponse] $ViewUserResponse = $ws.ViewUser($samAccountName, "SystemLogin", $null, $null, $null, $false, $null) if ($ViewUserResponse.IsActive) { Write-Host "Is user active in REL:" $samAccountName } } catch { } } pause [Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy61rvices_PersonnelManagement_svc.PersonnelManagementInactivateUserResponse] $response = $ws.InactivateUser($samAccountName, "SystemLogin", $null, $null, $null) Write-Host "Messages:" $response.Messages [Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy61rvices_PersonnelManagement_svc.PersonnelManagementViewUserResponse] $ViewUserResponse = $ws.ViewUser($samAccountName, "SystemLogin", $null, $null, $null, $false, $null) Write-Host "Is user active:" $ViewUserResponse.IsActive pause [Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy61rvices_PersonnelManagement_svc.PersonnelManagementActivateUserResponse] $ActivateResponse = $ws.ActivateUser($samAccountName, "SystemLogin", $null, $null, $null) Write-Host "Messages:" $ActivateResponse.Messages [Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy61rvices_PersonnelManagement_svc.PersonnelManagementViewUserResponse] $ViewUserResponse = $ws.ViewUser($samAccountName, "SystemLogin", $null, $null, $null, $false, $null) Write-Host "Is User Active:" $ViewUserResponse.IsActive |