-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxmlstuff.ps1
48 lines (32 loc) · 1.02 KB
/
xmlstuff.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# import the xmlfile with the user names
function createpw {
$global:pw = -join ((65..90) + (97..122) | Get-Random -Count 10 | % {[char]$_})
$pw
}
$file = "C:\Temp\users.xml"
function import ($file){
$numbers = 1..250
[xml]$xml = Get-Content $file
$xml.users.user
foreach ($number in $numbers){
createpw
$new_user = $xml.CreateElement("user")
$xml.users.AppendChild($new_user)
$new_user.SetAttribute("name", "user$($number)")
$new_user.SetAttribute("Pw", $global:pw)
}
$xml.Save("C:\Temp\users.xml")
}
# create a log file with this pattern -> NOT as xml. its like this:
# ERROR: Something went wrong
# INFO: Something happened
# ...
function logging ($list, $file) {
# $log = logmesagge
$logfile = "C:\Temp\log.log"
Add-Content -Value $log -Path $logfile
}
# export the list of all created users together with their password as xml file
function export ($list, $file) {
# wird garnüm brucht oder?
}