虽然在验证是否已完成时无法正常工作?

时间:2019-05-15 11:21:16

标签: powershell active-directory

问题在于,有时未设置电子邮件地址和设置homefolder权限。 我遇到了很多错误,并修复了这些错误,但是我遇到了一个问题,即在第2步中,脚本没有执行任何操作。

第1步

$date = (Get-Date -Format "g")
Write-Color "[1/5] [$date] ", "Creating Windows-account ", "..." -Color yellow,cyan,yellow
while (!$NewADVar) {
    $NewADVar = New-ADUser @NewADSplat -PassThru -ErrorAction Stop 
}
Start-Sleep 2
Add-ADGroupMember "Pilot-C" -Members $UserID # 
Get-ADuser -Identity $copy5 -Properties memberof |
    Select-Object memberof -ExpandProperty memberof |
    Add-AdGroupMember -Members $UserID
Get-ADUser $UserID -Properties userPrincipalName | ForEach-Object {
    Set-ADUser $_ -UserPrincipalName "$($_.samaccountname)@int.null.tld"
}
Set-ADTSProperties $UserID -AllowLogon 1 -TSProfilePath "\\int.null.tld\Users\TSProfiles\$UserID\"
Set-ADUser $UserID -ProfilePath "\\int.null.tld\Users\Profiles\$UserID\"
Start-Sleep 2

这是步骤2

Write-Color "[2/5] [$date] ", "Creating ", "folders ", "& ", "apply rights ", "..." -Color cyan,yellow,cyan,yellow,cyan,yellow  
$date = (Get-Date -Format "g")
New-Item -ItemType Directory -Path "\\int.null.tld\Users\Profiles\$UserID\" | Out-Null
New-Item -ItemType Directory -Path "\\int.null.tld\Users\TsProfiles\$UserID\" | Out-Null
New-Item -ItemType Directory -Path "\\int.null.tld\Users\users\$UserID\" | Out-Null
Import-Module -Name "\\int.null.tld\null\Org\ICT\NULL\SD\PS-Modules\NTFSSecurity\NTFSSecurity\NTFSSecurity.psm1" |
    Execution-Policy Unrestricted
while (!$Add_NTFSAccess_1) {
   $Add_NTFSAccess_1 = Add-NTFSAccess -Path "\\int.null.tld\Users\Profiles\$UserID\" -Account $UserID -AccessRights FullControl
}
while (!$Add_NTFSAccess_2) {
    $Add_NTFSAccess_2 = Add-NTFSAccess -Path "\\int.null.tld\Users\TsProfiles\$UserID\" -Account $UserID -AccessRights FullControl
}
while (!$Add_NTFSAccess_3) {
    $Add_NTFSAccess_3 = Add-NTFSAccess -Path "\\int.null.tld\Users\users\$UserID\" -Account $UserID -AccessRights FullControl
}
Start-Sleep 5 

我在做什么错了?

0 个答案:

没有答案