This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
userspace:opsi2ad [2014/02/10 11:22] dkoch |
userspace:opsi2ad [2021/08/23 08:37] (current) |
||
---|---|---|---|
Line 4: | Line 4: | ||
- 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 DATABASE-HOST DATABASEUSER PASSWORD DATABASE and YOUR-DOMAIN-SUFFIX to fit for your setup | + | - Replace |
- Make sure your MySQL server listens ( bind-address in my.cnf ) | - Make sure your MySQL server listens ( bind-address in my.cnf ) | ||
- | - Run this script as Domain-Administrator on an DC | + | - Execute |
+ | 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 29: | Line 30: | ||
Import-Csv ./ | Import-Csv ./ | ||
ForEach-Object { | ForEach-Object { | ||
- | $hostId += $_.hostId.ToUpper().Replace(" | + | $hostId += $_.hostId.ToUpper().Replace(" |
$description += $_.description | $description += $_.description | ||
Line 41: | Line 42: | ||
$olddescription= $olddescription.Trim() | $olddescription= $olddescription.Trim() | ||
- | echo " | + | echo "[$timestamp] |
dsmod computer $hostou -desc " | dsmod computer $hostou -desc " | ||