我目前正在为 AD 编辑我们的新员工脚本,但遇到了一个问题,我为主文件夹添加了 2 个单选按钮,一个单选按钮将 BaseHomeFolderPath 更新为 Path1,第二个单选按钮将其更新为 Path2,我导出变量到 csv 以验证它是否有效,但它一直显示为空白。我不知道这是范围问题还是我做错了什么,任何帮助将不胜感激!下面是代码的副本。
我尝试使用 $script: 并且它也不起作用。
$BaseHomeFolderPath = ''
Set-Variable -Name $BaseHomeFolderPath -Scope Global
$radiobuttonAtlas_MouseClick = [System.Windows.Forms.MouseEventHandler]{
#Event Argument: $_ = [System.Windows.Forms.MouseEventArgs]
#TODO: Place custom script here
$BaseHomeFolderPath = '\\path1\users'
}
$radiobuttonCerberus_MouseClick=[System.Windows.Forms.MouseEventHandler]{
#Event Argument: $_ = [System.Windows.Forms.MouseEventArgs]
#TODO: Place custom script here
$BaseHomeFolderPath = '\\path2\users'
}
$buttonRun_MouseClick=[System.Windows.Forms.MouseEventHandler]{
#Event Argument: $_ = [System.Windows.Forms.MouseEventArgs]
#TODO: Place custom script here
$TestValue = New-Object System.Object
$TestValue | Add-Member -MemberType NoteProperty -Name "Path" -Value $BaseHomeFolderPath
$TestValue | Export-CSV -NoTypeInformation -Path "C:\Users\testuser\Desktop\Testcsv.csv"
}
我希望 BaseHomeFolderPath 变量更新为选择的单选按钮。