Powershell with admin rights and command

Hello everybody,
I need for the copying of data partially admin rights. For this reason, I start a PS1 file with normal rights and would like to run from this script a powershell with admin rights.
My previous code:

[pre] $App = “Test”
$AppPath = ${env:ProgramFiles(x86)} + “\Manufacturer” + $App
$TmpPath = “C:\temp”
$TmpFiles = $TmpPath + “*.*”
$Command = ‘Copy-Item -Filter *.rpt -Path ’ + $TmpFiles + ’ -Recurse -Force -Destination "’ + $AppPath +’"’
start-process -FilePath “powershell” -ArgumentList “Copy-Item -Filter *.rpt -Path $TmpFiles -Recurse -Force -Destination “$AppPath”” -Verb runas[/pre]

I get the same exception every time:

Start-Process : No positional parameter was found, which is the argument “C:\Program Files (x86)\Manufacturer\Test” accepted.
In line: 6 characters: 1
+ start-process -FilePath “powershell” -ArgumentList "Copy-Item -Filter …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:slight_smile: [Start-Process], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.StartProcessCommand

Does anyone know what I’m doing wrong? Or you can not pass commands like that?

Many thanks for your quick help …


Got messed up with double quotes. Try below. You don’t need to use + for string concatenation in PowerShell. Double quotes here can do magic.

$App = "Test"
$AppPath = "${env:ProgramFiles(x86)}\Manufacturer\$App"
$TmpPath = "C:\temp"
$TmpFiles = "$TmpPath\*.*"
$Command = "Copy-Item -Filter *.rpt -Path '$TmpFiles' -Recurse -Force -Destination '$AppPath'"
start-process -FilePath powershell -ArgumentList $Command -Verb runas

It works very well. Thank you for your help