Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
devel:documentation:systems:dev:how_to_write_scripts_for_winrm_ad_connector [2019/09/05 11:46] kucerar ps example |
devel:documentation:systems:dev:how_to_write_scripts_for_winrm_ad_connector [2019/10/08 13:05] fiserp [Powershell] |
||
---|---|---|---|
Line 9: | Line 9: | ||
This is example create script | This is example create script | ||
- | < | + | < |
# | # | ||
# -*- coding: utf-8 -*- | # -*- coding: utf-8 -*- | ||
Line 60: | Line 60: | ||
This is example search script so I can show handling of response | This is example search script so I can show handling of response | ||
- | < | + | < |
# Search script, which will return information about user's exchange account | # Search script, which will return information about user's exchange account | ||
# INPUT: | # INPUT: | ||
Line 66: | Line 66: | ||
Write-Host "PS Search started" | Write-Host "PS Search started" | ||
+ | |||
#Needed to load Exchange cmdlets | #Needed to load Exchange cmdlets | ||
Add-PSSnapin -Name ' | Add-PSSnapin -Name ' | ||
Line 74: | Line 75: | ||
try { | try { | ||
#$uid will be replace with some value from python, in case that search is for all (reconcilation) we will have empty string here that's the reason why we are assigning the value to new variable | #$uid will be replace with some value from python, in case that search is for all (reconcilation) we will have empty string here that's the reason why we are assigning the value to new variable | ||
+ | | ||
$identificator = " | $identificator = " | ||
$obj | $obj | ||
Line 91: | Line 93: | ||
| | ||
# prepare list | # prepare list | ||
+ | | ||
$resultList = @() | $resultList = @() | ||
- | # Iterate thru response object | + | # Iterate thru response object |
foreach ($item in $obj) { | foreach ($item in $obj) { | ||
| | ||
Line 99: | Line 102: | ||
$resultMap = @{ } | $resultMap = @{ } | ||
| | ||
- | # iterate thru each result | + | # iterate thru each result |
foreach ($attr in $item.psobject.Properties) { | foreach ($attr in $item.psobject.Properties) { | ||
+ | | ||
# care only about attributes which has some value | # care only about attributes which has some value | ||
if (![string]:: | if (![string]:: | ||
Line 107: | Line 111: | ||
| | ||
$resultMap.add(" | $resultMap.add(" | ||
+ | | ||
# now we need to fill __UID__ and __NAME__ attribute as connid needs this values | # now we need to fill __UID__ and __NAME__ attribute as connid needs this values | ||
if ($name -eq " | if ($name -eq " |