Import-Module activedirectory
[string]$Name = "Larry Page"
Get-ADUser -Filter 'Name -like "$Name"'
How do I get the name into the variable? At execution, it doesn't appear to substitute the name at runtime
Import-Module activedirectory
[string]$Name = "Larry Page"
Get-ADUser -Filter 'Name -like "$Name"'
How do I get the name into the variable? At execution, it doesn't appear to substitute the name at runtime
You have the quotes flipped. Variable substitution only happens with double quoted strings. The first set of single quotes tells PowerShell to not do the substitution. If you use double quotes on the outside, you can use the singles inside and still get the substitution.
Import-Module activedirectory
[string]$Name = "Larry Page"
Get-ADUser -Filter "Name -like '$Name'"