I am using PowerShell to mass move PC’s into designated OU based on naming format. I currently have the script working when pulling names from a file, but when replacing the line of code pointing to the file with the ‘Get-ADComputer -Filter *’ command, nothing happens.
It’s gonna be hard to recommend something meaningful when we have to guess what code exactly you’re using. I’d say it is pretty likely that you use a plain text file as input file and so your input values are of the type string. When you change this to an AD query the type is probably a little more complex object with according properties where you have to pick the proper property.
Sorry about that, basically I’m trying to take this
$LISTPC = Get-Content C:\TEST.csv
$LISTPC|Foreach{
SWITCH -Wildcard ($LISTPC)
{
‘1798*’
{
Get-ADComputer $_|Move-ADObject -TargetPath “PATH HERE”
And modify it to search for all PC’s on the domain, with the eventual goal of changing the ‘1798*’ to a naming scheme.
I believe the issue is what you were getting at, as if i have the ‘$LISTPC = Get-ADComputer -Filter * | Select -Property Name’ line export to a .txt file, i get every PC name in quotations.
I assumed this was causing the issue and used -replace to remove the quotations with no luck.
When you post code, sample data, console output or error messages please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.