powershell - 尝试在电话便笺中添加创建日期并输入当前日期,但只能获得“创建日期”
问题描述
使用下面的代码,我试图添加一个不是“创建于”,然后给出当前日期,但日期不填充。提前致谢...
Get-ADuser -Identity $username -Properties info |
ForEach-Object{
$info = $_.Info
$_|Set-ADuser -Replace @{info="$Info`n Created on $date"}
}
解决方案
您尚未$date
在脚本中的任何地方定义。尝试以下操作:
Get-ADuser -Identity $username -Properties info |
ForEach-Object{
$info = $_.Info
$date = Get-Date
$_|Set-ADuser -Replace @{info="$Info`n Created on $date"}
}
推荐阅读
- python - 如何将等长字符串分解为 Pandas DataFrame 列(没有空列)
- excel - 在公式中偏移 ActiveCell
- sql - 如何在 PostgreSQL 中向用户授予存储过程创建权限
- c# - 从 C#/.NET 正确编辑文本或源文件
- selenium - 如何在behat的所见即所得编辑器中输入textarea
- php - 如何添加和删除
- azure - 如何修复 AzurePowerShell 管道任务中的语法错误?
- python - 我想在我拥有的数据框中取除一列之外的所有列的平均值
- windows-runtime - 相互依赖的 Windows 运行时依赖项属性
- asp.net-core - 如何从 ML.NET 中的 ML 模型的 ITransformer 获取训练 PipleLine