Run PowerShell script (installation of .exe file in silient model) in Vagrant box

假装没事ソ 提交于 2020-01-06 18:13:53

问题


I have script which installs software (.exe file) via PowerShell

Get-ChildItem "D:\" -Filter *.exe | Where Name -NotMatch '.*NoDB\.exe$'  | % {
New-Object psobject -Property @{
No = [int]([regex]::Match($_.Name, '(?<=CL)\d+').Value)
Name = $_.FullName
}

} | Sort No -Descending | Select -ExpandProperty Name -First 1 | 
Foreach { & $_ -s2 -sp"-SilentInstallation=standalone-  UpdateMaterials=yestoall -UpgradeDBIfRequired=yes"}

I need to run this script via PowerShell so I created a script for this

# copy installation script to Vagrant folder

Copy-Item -Path "C:\Users\Username\Desktop\Scripts\Installation_Ortho.ps1" -Destination "C:\VagrantBoxes\Win8"

 # Navigate to vagrant folder

 CD "C:\VagrantBoxes\Win8"

  #vagrant powershell

 vagrant.exe powershell

 # navigate to the folder which is shared with Vagrant

 CD "C:\vagrant"

Unfortunately I receive an error

 C:\VagrantBoxes\Win8> vagrant powershell
==> default: Detecting if a remote PowerShell connection can be made with the guest...
default: Creating powershell session to 127.0.0.1:55985
default: Username: vagrant

Oops, something went wrong.  Please report this bug with the details  below.
Report on GitHub: https://github.com/lzybkr/PSReadLine/issues/new

Last 0 Keys:


Exception:
System.IO.IOException: The handle is invalid.

at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.Console.GetBufferInfo(Boolean throwOnNoConsole, Boolean& succeeded)
at Microsoft.PowerShell.PSConsoleReadLine.Initialize(Runspace runspace, EngineIntrinsics engineIntrinsics)
at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics)

I am looking for solution which helps me:

1) Navigate through PowerShell to a folder inside Vagrant box where script is placed;

2) Execute a PowerShell script inside Vagrant box and receive installed software in Vagrant boxe.

来源:https://stackoverflow.com/questions/37944980/run-powershell-script-installation-of-exe-file-in-silient-model-in-vagrant-bo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!