获取14天前创建的Powershell用户列表
我有一个脚本来提取获取14天前创建的Powershell用户列表,powershell,Powershell,我有一个脚本来提取'CW-OTHER'属性 但我现在需要的是告诉这个命令,我只想让你提取那些创建的名称: 14“之前” 我试着为它定义一个变量。根本不锻炼;不断出现语法错误 任何帮助都将不胜感激 $thedate = get-date -date $(get-date).adddays(-14) -format yyyy-MM-dd Get-ADUser -Filter { Title -eq 'CW - OTHER' -and whencreated $thedate } -Propertie
'CW-OTHER'
属性
但我现在需要的是告诉这个命令,我只想让你提取那些创建的名称:
14“之前”
我试着为它定义一个变量。根本不锻炼;不断出现语法错误
任何帮助都将不胜感激
$thedate = get-date -date $(get-date).adddays(-14) -format yyyy-MM-dd
Get-ADUser -Filter { Title -eq 'CW - OTHER' -and whencreated $thedate } -Properties DisplayName, EmailAddress, Title `
| select DisplayName, EmailAddress, Title `
| Export-CSV "C:\Scripts\Email_Addresses.csv"
问题:
格式化日期将日期转换为字符串。您的筛选器的第二部分没有比较运算符。我刚刚计算出来。谢谢欢迎来到Stack Overflow-请阅读OP不会注意到这一点,除非您使用@shawnb23“ping”
$thedate = (Get-Date).AddDays(-14)
Get-ADUser -Filter { Title -eq 'CW - OTHER' -and whencreated -gt $thedate } -Properties DisplayName, EmailAddress, Title `
| select DisplayName, EmailAddress, Title `
| Export-CSV "C:\Scripts\Email_Addresses.csv" -NoTypeInformation