sof*_*fun 1 powershell active-directory
Import-Module activedirectory
[string]$Name = "Larry Page"
Get-ADUser -Filter 'Name -like "$Name"'
Run Code Online (Sandbox Code Playgroud)
如何将名称输入变量?在执行时,似乎没有在运行时替换名称
您的报价被翻转了。变量替换仅在双引号字符串中发生。第一组单引号告诉PowerShell不要进行替换。如果在外部使用双引号,则可以在内部使用单引号,但仍然可以得到替换。
Import-Module activedirectory
[string]$Name = "Larry Page"
Get-ADUser -Filter "Name -like '$Name'"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
37 次 |
| 最近记录: |