Im trying to pass a credential to another powershell script but i get an error as
"Cannot convert the "System.Management.Automation.PSCredential" value of type "System.String" to type "System.Management.Automation.PSCredential""
This is the script which invoke the psscript
param(
$vcenterserver,
[System.Management.Automation.Credential()]$vccredential
)
#New-Item C:\dcpromotxt\1.ps1 -ItemType file -Force
#Start-Process powershell.exe -ArgumentList "-NoExit -File '& 'C:\dcpromotxt\1.ps1''" -vcenterserver $vcenterserver -vccredential $vccredential
Start-Process powershell -ArgumentList "-NoExit -File '& 'C:\dcpromotxt\1.ps1''","$vcenterserver","$vccredential"
and here is the 1.ps1
param(
$vcenterserver,
$vccredential
)
Connect-VIServer $vcenterserver -Credential $vccredential
start-sleep 120
.ps1
file in current session? – user4003407