User Tools

Site Tools


en:powershell:advanced

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
en:powershell:advanced [2021/03/15 21:24] – [Advanced] lonclegren:powershell:advanced [2021/03/16 21:51] (current) lonclegr
Line 9: Line 9:
  
  
-Now let's discover how to query one Active Directory. First one new PowerShell module is required to deal with AD.+Now let's discover how to query one Active Directory. First new PowerShell module is required to deal with AD.
  
 <code powershell> <code powershell>
Line 32: Line 32:
 </file> </file>
  
-Before we tested mail addresses in an easy way : //does it end with "domain.com" ?//. New tests with AD queries, //Samaccountname must belong to an active user from AD and AD user mail must be equal to mail from CSV file//.+Previously we tested mail addresses in an easy way : //does it end with "domain.com" ?//. New tests with AD queries, //Samaccountname must belong to an active user from AD and AD user mail must be equal to mail from CSV file//.
  
 <file powershell csvLevel2.ps1> <file powershell csvLevel2.ps1>
Line 39: Line 39:
 Import-Csv -Path input.csv | foreach { Import-Csv -Path input.csv | foreach {
  
-    # save current object into different variable+    # save current object into a local variable
     $currentLine = $_     $currentLine = $_
  
-    # deal with columns+    # retrieve columns
     $mail = $currentLine.Mail     $mail = $currentLine.Mail
     $sam = $currentLine.Samaccountname     $sam = $currentLine.Samaccountname
Line 81: Line 81:
 # export result line by line to CSV # export result line by line to CSV
 # -NoTypeInformation prevents metadata from being exported # -NoTypeInformation prevents metadata from being exported
-# -Encoding is specified because of the fact we are querying AD (UTF-8)+# -Encoding is specified because we are querying AD (UTF-8)
 Export-Csv -Path preCheck.csv -NoTypeInformation -Encoding UTF-8 Export-Csv -Path preCheck.csv -NoTypeInformation -Encoding UTF-8
 </file> </file>
en/powershell/advanced.1615857880.txt.gz · Last modified: 2021/03/15 21:24 by lonclegr