Options in Powershell_ISE from the command line

I developed a script in Powershell_ISE to backup a SQL Server database on one server, move the file to another server, and restore to the target server with a different database name. It works great.

It uses 6 required parameters. In Powershell_ISE, I can run

    C:\PowershellScripts\Servers\CRMBackup.ps1 -SrcSrv uk-sb-sql12\wss -SrcDb UAT_2016_MSCRM
     -SrcBak \\uk-sb-sql12\backup\ -TrgSrv uk-sb-sql12\wss -TrgDb preprod_mscrm66 -TrgBak 
     \\uk-sb-sql12\backup\

and it works great.

I can not get it to work from the command line. How to achieve this?

If I run

    powershell_ise.exe "C:\PowershellScripts\Servers\CRMBackup.ps1" -SrcSrv uk-sb-sql12\wss 
    -SrcDb UAT_2016_MSCRM -SrcBak \\uk-sb-sql12\backup\ -TrgSrv uk-sb-sql12\wss -TrgDb 
    preprod_mscrm66 -TrgBak \\uk-sb-sql12\backup\

from the command line I get the error message:

Powershell_ISE parameter error

If I call Powershell instead of Powershell_ISE, everything is fine:

    powershell.exe "C:\PowershellScripts\Servers\CRMBackup.ps1" -SrcSrv uk-sb-sql12\wss 
    -SrcDb UAT_2016_MSCRM -SrcBak \\uk-sb-sql12\backup\ -TrgSrv uk-sb-sql12\wss -TrgDb 
    preprod_mscrm66 -TrgBak \\uk-sb-sql12\backup\

succeeds:

Successful launch from Powershell

Can someone tell me how to pass command line options to Powershell_ISE?

thank

+4
3

Powershell_ISE .

:

PowerShell ISE ( - ), powershell.exe . -:

  • DOS, powershell.exe, .
  • PowerShell, C:\PowershellScripts\Servers\CRMBackup.ps1
  • Windows ( ...)
  • CI (Jenkins, TeamCity...)

, PowerShell ISE , , "" ( F5), . script powershell_ise.exe.

+2

? (powershell.exe powershell_ise.exe)

powershell.exe "C:\PowershellScripts\Servers\CRMBackup.ps1" -SrcSrv uk-sb-sql12\wss -SrcDb UAT_2016_MSCRM -SrcBak \\uk-sb-sql12\backup\ -TrgSrv uk-sb-sql12\wss -TrgDb preprod_mscrm66 -TrgBak \\uk-sb-sql12\backup\
+1

Source: https://habr.com/ru/post/1652598/


All Articles