need assistance with this powershell script

hello, I'm trying to run the following powershell script [using the quest commandlets] and receiving the following error:
the term 'displayname' is not recognized as the name of a cmdlet.

any assistance would be much appreciated.

S.
# Move mailboxes by security group 
Write-Host "You have choosen to migrate mailboxes by specifying an AD security group" 
$ADSecGroupName = Read-Host "Enter AD security group that you want to migrate" 
Get-QADUser -MemberOf $ADSecGroupName | ft 
Write-Host "The above list of users will get migrated!!" 
Write-Host " " 
Get-MailboxDatabase | ft 
$TargetDatabaseName = Read-Host "Type the database that you want to migrate user(s) to" 
#  
#Loop through each mailbox 
foreach ($mailbox in (Get-QADUser -MemberOf $ADSecGroupName)) 
{$displayname = $mailbox.Displayname 
New-MoveRequest -Identity $displayname -TargetDatabase $TargetDatabaseName -BadItemLimit 50}

Open in new window

siber1Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Chris DentPowerShell DeveloperCommented:
Hmm I can't reproduce that error using the code you've posted. Is that exactly as you have it? No extra line-breaks? Nothing missed?

Chris
0
Chris DentPowerShell DeveloperCommented:
Oh yes, the error message will have more information than that, would you be able to share it?

Cheers!

Chris
0
siber1Author Commented:
sure Chris. here is the exact error that is generated when i run it
The term 'displayname' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\Users\admin\Desktop\test.ps1:14 char:13
+ {displayname <<<<  = $mailbox.Displayname
    + CategoryInfo          : ObjectNotFound: (displayname:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

A positional parameter cannot be found that accepts argument 'Identity'.
    + CategoryInfo          : InvalidArgument: (:) [New-MoveRequest], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,New-MoveRequest

The term 'displayname' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\Users\admin\Desktop\test.ps1:14 char:13
+ {displayname <<<<  = $mailbox.Displayname
    + CategoryInfo          : ObjectNotFound: (displayname:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

A positional parameter cannot be found that accepts argument 'Identity'.
    + CategoryInfo          : InvalidArgument: (:) [New-MoveRequest], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,New-MoveRequest

The term 'displayname' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\Users\admin\Desktop\test.ps1:14 char:13
+ {displayname <<<<  = $mailbox.Displayname
    + CategoryInfo          : ObjectNotFound: (displayname:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

A positional parameter cannot be found that accepts argument 'Identity'.
    + CategoryInfo          : InvalidArgument: (:) [New-MoveRequest], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,New-MoveRequest

Open in new window

0
Chris DentPowerShell DeveloperCommented:
Ahh there it is :)

In your snippet you have a $ here:

{$displayname = $mailbox.Displayname

In your script, test.ps1, the first $ is missing. That changes $displayname from a variable to a command and is where it's getting hung up.

Cheers,

Chris
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
siber1Author Commented:
ahh.. yes thats it!
works perfect now.

many thanks Chris!

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.