powershell - Powershell 4.0 - 新的 GUID 生成问题
问题描述
当尝试在脚本下运行时,我收到以下错误消息。我正在使用 Powershell 4.0
错误:
Method invocation failed because [System.Guid] does not contain a method named 'new'.
At line:13 char:3
+ $ObjectGUID = [guid]::new($ADObject)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound
脚本 :
$Identity = "user01"
try
{
$ADObject = ([adsisearcher]"samAccountName=$Identity").FindOne() | foreach {$_.GetDirectoryEntry() | Select-Object -ExpandProperty ObjectGUID}
}
catch
{
Write-Error -Message "Error while querying $Identity"
Break
}
$ObjectGUID = [guid]::new($ADObject)
解决方案
推荐阅读
- azure - 在 Azure Active Directory 身份验证中提供用户参数
- node.js - 无服务器部署错误:找不到模块'/Users/.../--max-old-space-size=2048'
- c - 在 C 中每个块的顶部声明变量的基本原理?
- angular - 路由到孩子时找不到Angular 10辅助路由
- regex - Bash 中的正则表达式或 Grep
- c++ - xcode中的指令后缩进不起作用
- azure - 在 docker compose 上为 Azurite 自定义存储帐户
- javascript - 无法读取未定义的属性“输入”
- python - 删除数据框中的科学记数法浮点数
- f# - 如何使用户能够下载寓言中的文件?