Differences

This shows you the differences between two versions of the page.

Link to this comparison view

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:04]
fiserp [Python]
Line 9: Line 9:
  
 This is example create script This is example create script
-<code>+<code python>
 #!/usr/bin/env python #!/usr/bin/env python
 # -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
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 '*Exchange*' Add-PSSnapin -Name '*Exchange*'
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 = "$uid"     $identificator = "$uid"
     $obj     $obj
Line 91: Line 93:
          
     # prepare list     # prepare list
 +    
     $resultList = @()     $resultList = @()
  
-    # Iterate thru response object+    # Iterate thru response object e.g. We get 10 users so we need to create map for each of them inside this loop and add it to list
     foreach ($item in $obj) {     foreach ($item in $obj) {
                  
Line 99: Line 102:
         $resultMap = @{ }         $resultMap = @{ }
                  
-        # iterate thru each result e.g. We get 10 users so we need to create map for each of them+        # iterate thru each result attributes
         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]::IsNullOrWhitespace($attr.Value)) {             if (![string]::IsNullOrWhitespace($attr.Value)) {
Line 107: Line 111:
                          
                 $resultMap.add("$name", "$value")                 $resultMap.add("$name", "$value")
 +                  
                 # 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 "SamAccountName") {                 if ($name -eq "SamAccountName") {
  • by kucerar