userspace:opsi2ad
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| userspace:opsi2ad [2014/02/10 12:15] – dkoch | userspace:opsi2ad [2021/08/23 10:37] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== OPSI2AD ====== | ====== OPSI2AD ====== | ||
| + | --- // | ||
| This script synchronizes the client descriptions from OPSI to the AD. | This script synchronizes the client descriptions from OPSI to the AD. | ||
| - | You will have to store a mysql.exe binary in the same directory as the script. | ||
| + | - You will have to store a mysql.exe binary in the same directory as the script. | ||
| + | - Replace > | ||
| + | - Make sure your MySQL server listens ( bind-address in my.cnf ) | ||
| + | - Execute this script as Domain-Administrator on an DC | ||
| + | |||
| + | |||
| + | This Script requires Powershell 3 | ||
| <code powershell> | <code powershell> | ||
| # This script synchronizes the client descriptions from OPSI to the AD | # This script synchronizes the client descriptions from OPSI to the AD | ||
| + | $timestamp=Get-Date -format u | ||
| # Connect to the MYSQL of OPSI and crete a csv with $hostId and $description | # Connect to the MYSQL of OPSI and crete a csv with $hostId and $description | ||
| echo " | echo " | ||
| chcp 850 | chcp 850 | ||
| echo "SET NAMES ' | echo "SET NAMES ' | ||
| - | ./mysql.exe --default-character-set=utf8 -hDATABASE-HOST -uDATABASEUSER | + | ./mysql.exe --default-character-set=utf8 -h> |
| # Convert SQL output to valid CSV output | # Convert SQL output to valid CSV output | ||
| Line 22: | Line 30: | ||
| Import-Csv ./ | Import-Csv ./ | ||
| ForEach-Object { | ForEach-Object { | ||
| - | $hostId += $_.hostId.ToUpper().Replace(" | + | $hostId += $_.hostId.ToUpper().Replace(" |
| $description += $_.description | $description += $_.description | ||
| Line 34: | Line 42: | ||
| $olddescription= $olddescription.Trim() | $olddescription= $olddescription.Trim() | ||
| - | echo " | + | echo "[$timestamp] |
| dsmod computer $hostou -desc " | dsmod computer $hostou -desc " | ||
userspace/opsi2ad.1392030925.txt.gz · Last modified: (external edit)
