当我运行下面的代码时,我在csv中获得的数据没有我期望的服务器名称。
相反,这就是我在.csv文件中获得的内容
Length 204
为什么会这样?
$varoutfile = "\\unc_path\server $(get-date -f yyyy-MM).csv"
$varDOW = (get-date).DayOfWeek
$varservertoreboot = "server1" , "server2" , "server1" ,
if ($varDOW -eq "Sunday") {
foreach ($server in $varservertoreboot) {
Restart-Computer $varservertoreboot -Force
"$(get-date -f yyyy-MM-dd-HH-mm-ss) Today is $vardow, The system
$varservertoreboot is rebooting" | Export-Csv $varoutfile -Append -NoClobber -NoTypeInformation
}
}
else {}
if ($varDOW -eq "Wednesday") {
foreach ($server in $varservertoreboot) {
Restart-Computer $varservertoreboot -Force
"$(get-date -f yyyy-MM-dd-HH-mm-ss) Today is $vardow, The system $varservertoreboot is rebooting" | Export-Csv $varoutfile -Append -NoClobber
}
}
答案 0 :(得分:1)
我替换:
req.headers.authorization
使用:
req.get('authorization')