使用 Quest powershell cmdlet 更改 Active Directory 中用户的个人资料信息
尝试循环遍历活动目录中的 OU,然后更改该 OU 中所有用户的配置文件下的 HomeDirectory 和 HomeDrive。我遇到的唯一问题是当我在 HomeDirectory 的路径中使用环境变量 %USERNAME% 时,它无法正确映射。它将映射到 home 文件夹,但不会映射到 %USERNAME%。如何让它映射到 %USERNAME% 文件夹?我使用了错误的变量吗?非常感谢任何帮助。下面是我的 powershell 代码:
#Add Snapin for Get-QADuser
Add-PSSnapin Quest.ActiveRoles.ADManagement
#Set OU variable
set-variable -name OU -value "domain.local/Test"
#Get members of OU then set HomeDirectory and HomeDrive of each user in OU
get-qaduser -searchroot $OU | set-QADUser -HomeDirectory '\\server\homes\%USERNAME%' -HomeDrive 'H:'
Trying to loop through an OU in active directory and then change the HomeDirectory and HomeDrive under profile for all users in said OU. The only problem I have is when I use the environment variable %USERNAME% in the path of the HomeDirectory it doesn't map correctly. It will map to the homes folder, but not to the %USERNAME%. How do I get it to map down to the %USERNAME% folder? Am I using the wrong variable? Any help is greatly appreciated. Here's my powershell code below:
#Add Snapin for Get-QADuser
Add-PSSnapin Quest.ActiveRoles.ADManagement
#Set OU variable
set-variable -name OU -value "domain.local/Test"
#Get members of OU then set HomeDirectory and HomeDrive of each user in OU
get-qaduser -searchroot $OU | set-QADUser -HomeDirectory '\\server\homes\%USERNAME%' -HomeDrive 'H:'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要使用每个传入用户帐户的 SamAccountName
You need to use the SamAccountName of each incoming user account
你必须这样做:
请注意,它也是双引号而不是单引号。
You have to do it like this:
Note that it is double quotes as well and not single.