- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想从这个脚本中排除禁用的用户,但似乎无法找到我如何尝试 -exclude 但没有运气。
如果你也有更好的方法来接受建议
import-module ActiveDirectory;
$maxPasswordAgeTimeSpan = (Get-ADDefaultDomainPasswordPolicy).MaxPasswordAge
Get-ADUser -filter * -properties PasswordLastSet, PasswordExpired, PasswordNeverExpires, EmailAddress, GivenName | foreach {
$today=get-date
$UserName=$_.GivenName
$Email=$_.EmailAddress
if (!$_.PasswordExpired -and !$_.PasswordNeverExpires) {
$ExpiryDate=$_.PasswordLastSet + $maxPasswordAgeTimeSpan
$DaysLeft=($ExpiryDate-$today).days
if ($DaysLeft -lt 10 -and $DaysLeft -gt 0){
$WarnMsg = "
<p style='font-family:arial'>Bonjour $UserName,</p>
<p style='font-family:arial'>Votre mot de passe va expirer dans $DaysLeft jours, S.V.P. changer votre mot de passe.</p>
<p style='font-family:arial'>Merci.</p>"
$enc = New-Object System.Text.utf8encoding
ForEach ($email in $_.EmailAddress) {
send-mailmessage -to test@test -from noreply@test.com -Subject "Votre mot de passe va expirer dans $DaysLeft jours" -body $WarnMsg -smtpserver x.x.x.x -BodyAsHtml -Encoding $enc }
}
}
}
最佳答案
只需将 Get-AdUser 中的过滤器从 *
更改为 'enabled -eq "true"'
Get-ADUser -filter 'enabled -eq "true"' -properties ...
关于powershell - 排除禁用用户 Get-aduser,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40493922/
我确定这只是一个语法错误,但我正在尝试搜索 AD 用户,但我无法弄清楚为什么这不起作用: Write-Host "Enter LastName or UserName:" $x = Read-Host
我在 DomainA 下的服务器上。我可以用 Get-ADUser它工作正常。 现在在 DomainA 和 DomainB 之间建立了信任。我想切换到 DomainB 并获取 OU=New Users
目前我有一个创建用户帐户的脚本。 注意:并非所有用户都具有相同的 UPN (UserPrincipalName) 用户帐户的格式如下: 。 如果冲突,格式将更改为: 最近我遇到了一个问题,用户的pro
Powershell 的新手,仍在尝试了解逻辑。 我想过滤掉特定 OU 中事件目录中的 samaccountname,该 OU 在字符串 (phil_test_adm) 的末尾也包含“adm”。找到用
希望您能提供帮助。当我发出以下命令时: $g = get-ADGroupMember -Server sbintldirectory.com -Identity group1 $n = get-ADG
我正在尝试将一些变量输入Powershell cmdlet New-ADuser中以自动创建用户。如果我对值进行硬编码,则此方法很好,但是当我尝试将其传递给变量时,出现以下错误: New-ADUser
我想从这个脚本中排除禁用的用户,但似乎无法找到我如何尝试 -exclude 但没有运气。 如果你也有更好的方法来接受建议 import-module ActiveDirectory; $maxPass
我尝试使用CSV文件设置属性“serialNumber”,但在按Enter键后仍然收到错误消息。 这是我的剧本 ipmo activedirectory $users = Import-Csv -Pa
我正在寻找您关于最佳方法的想法。 目标只是根据不同的可能输入来找到给定的用户。 可能是: $input = "John,Smith" $input = "John Smith" $input = "J
运行脚本时出现以下错误: Get-ADUser : A referral was returned from the server At line:25 char:70 + ... -Identity
这个问题在这里已经有了答案: Why doesn't $PSItem behave as expected when using a bracket-based -Filter argument? (
我正在尝试为 Powershell 编写一个脚本,该脚本将显示每个用户上次登录的日期/时间和上次更改密码的日期/时间,并根据他们在 Active Directory 中的组织单位分离数据。 我收到了许
这是我上一个问题Invoking powershell cmdlets from C#的继续 我想从C#中调用 Activity 目录cmdlet get-aduser,它采用的第一个参数是过滤器。我
我想检查系统中是否已存在用户帐户。 $SamAc = Read-Host 'What is your username?' $User = Get-ADUser -Filter {sAMAccount
我似乎无法解决这个问题来挽救我的生命。 我想捕获所有 AD 用户的 SAMAccountName 长度 等于 6。 我希望有这样的事情 Get-ADuser -filter "samaccountna
我需要在 AD 中查询自定义 extensionAttribute10 未设置或不等于特定值的用户。我使用该命令成功获得了值不等于 100 的用户: Get-ADUser -SearchBase "o
$users = get-aduser -filter 'extensionAttribute10 -notlike "*" -and proxyaddresses -like "*"' -Prope
很抱歉,如果这是之前已经回答过的问题,但我已经搜索了好几天,但找不到我正在寻找的任何东西(这令人困惑,因为这似乎是最简单的请求)。 我有一个跟踪委托(delegate)树(无关)的脚本,在其中,我需要
$name="d4rkcell" Get-ADUser -LDAPFilter "(sAMAccountName=$Name)" -Properties extensionAttribute12 我正
我正在尝试获取 AD 中具有电子邮件(邮件属性)的所有用户的列表。我有这个命令 Get-AdUser -filter * -Properties mail | Select SAMAccountNam
我是一名优秀的程序员,十分优秀!