我正在尝试创建一个Powershell脚本,该脚本将捕获所有已启用且在90天内处于非活动状态的Active Directory帐户。该脚本将提示用户在查询计算机或用户帐户之间进行选择。根据选择,它将作为变量传递给主命令。
如果我不传递变量,这些命令将正常工作。
我不确定我要做什么。
对不起,任何错误的代码格式。刚开始。
Clear-Host
write-host "`nProgram searches for Enabled AD users account that have not logged in for more than 90 days. `nIt searches the entire domain and saves the results to a CSV file on users desktop." "`n"
$choice = Read-host -Prompt " What do you want to search for Computer or Users Accounts`nType 1 for users`nType 2 for Computers`n`nChoice"
$account
if ($choice -eq 1){
$account = UsersOnly
}
Elseif($choice -eq 2){
$account = ComputersOnly
}
Else{ …Run Code Online (Sandbox Code Playgroud)