私はPowerShellを非常に使い慣れており、理解するのが難しいです。
PowerShellスクリプト内に.MSI
をインストールします。
それを行う方法や私に初心者レベルのチュートリアルを提供する方法を教えてください。PowerShellを使用して.MSIをインストールするには
$wiObject = New-Object -ComObject WindowsInstaller.Installer
?????
私はPowerShellを非常に使い慣れており、理解するのが難しいです。
PowerShellスクリプト内に.MSI
をインストールします。
それを行う方法や私に初心者レベルのチュートリアルを提供する方法を教えてください。PowerShellを使用して.MSIをインストールするには
$wiObject = New-Object -ComObject WindowsInstaller.Installer
?????
なぜそれほど気になるのですか?
または
Start-Process <path>\filename.msi
編集:スタート・プロセス・パラメータを使用でき
の全リスト:
msiexec /i "c:\package.msi"
だけで.msiファイルを呼び出します
さらにオプションのパラメータを追加することもできます。インストーラに固有の共通のmsiパラメータとパラメータがあります。一般的なパラメータの場合はmsiexec
PowerShellや他のコマンドシェルを初めてお使いの方は、@ Adiの回答の<path>
部分で混乱するかもしれません。
Windows GUIを使用してパスの値を確認するには、.msiファイルを右クリックし、[プロパティ]、[詳細]の順に選択します。 「フォルダパス」の下に、何が書き込まれる必要があるかがわかります。
ので、あなたのコマンドは
& C:\Users\YourName\YourDirectory\filename.msi
(例えば)のようになります。これはStackOverflowのを使用するほとんどの人には自明であるが、本当の初心者は簡単に道に迷って行くことができます。
私はこれを書き換えて相対的な回答の場所を避け、時間の経過とともに変更することができます – neontapir
ありがとう!私は今参照してください。 – ngks
そのような明確化は、コメントや示唆された編集として投稿されるべきであり、異なる方法で同じことを言う新しい回答としてではありません。いずれにせよ、PowerShellを最初に使用するのに十分コンピュータに精通している人なら誰でもそれを理解するのに問題はないと確信しています。私はまだ誰もがその種の表現を混乱させるのを見たことがありません。あなたはそれらをいつも答えて見ます。個人的には、あなたが持っている方法よりも優れたフォームだと思います。さらに、.msiがC:\ Usersにない場合、なぜ同じ仮想的なnoobもあなたの表現に混乱しないでしょうか? –
#Variables
$computername = Get-Content 'M:\Applications\Powershell\comp list\Test.txt'
$sourcefile = "\\server\Apps\LanSchool 7.7\Windows\Student.msi"
#This section will install the software
foreach ($computer in $computername)
{
$destinationFolder = "\\$computer\C$\download\LanSchool"
#This section will copy the $sourcefile to the $destinationfolder. If the Folder does not exist it will create it.
if (!(Test-Path -path $destinationFolder))
{
New-Item $destinationFolder -Type Directory
}
Copy-Item -Path $sourcefile -Destination $destinationFolder
Invoke-Command -ComputerName $computer -ScriptBlock { & cmd /c "msiexec.exe /i c:\download\LanSchool\Student.msi" /qn ADVANCED_OPTIONS=1 CHANNEL=100}
}
私はこのために、すべての上に自分自身を検索し、もちろんゼロを思い付いたが、最終的には一緒にこの作業スクリプトを石畳ていました。それは素晴らしい仕事です!他の誰かが恩恵を受けることを願って私がここに投稿すると思った。それはコンピュータのリストを引っ張り、ファイルをローカルマシンにコピーして実行します。 :)パーティー!
#$computerList = "Server Name"
#$regVar = "Name of the package "
#$packageName = "Packe name "
$computerList = $args[0]
$regVar = $args[1]
$packageName = $args[2]
foreach ($computer in $computerList)
{
Write-Host "Connecting to $computer...."
Invoke-Command -ComputerName $computer -Authentication Kerberos -ScriptBlock {
param(
$computer,
$regVar,
$packageName
)
Write-Host "Connected to $computer"
if ([IntPtr]::Size -eq 4)
{
$registryLocation = Get-ChildItem "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\"
Write-Host "Connected to 32bit Architecture"
}
else
{
$registryLocation = Get-ChildItem "HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\"
Write-Host "Connected to 64bit Architecture"
}
Write-Host "Finding previous version of `enter code here`$regVar...."
foreach ($registryItem in $registryLocation)
{
if((Get-itemproperty $registryItem.PSPath).DisplayName -match $regVar)
{
Write-Host "Found $regVar" (Get-itemproperty $registryItem.PSPath).DisplayName
$UninstallString = (Get-itemproperty $registryItem.PSPath).UninstallString
$match = [RegEx]::Match($uninstallString, "{.*?}")
$args = "/x $($match.Value) /qb"
Write-Host "Uninstalling $regVar...."
[diagnostics.process]::start("msiexec", $args).WaitForExit()
Write-Host "Uninstalled $regVar"
}
}
$path = "\\$computer\Msi\$packageName"
Write-Host "Installaing $path...."
$args = " /i $path /qb"
[diagnostics.process]::start("msiexec", $args).WaitForExit()
Write-Host "Installed $path"
} -ArgumentList $computer, $regVar, $packageName
Write-Host "Deployment Complete"
}
あなたは答えにいくつかのコメントをしなければなりません – ohlmar
いくつかの試行錯誤の末、特定のディレクトリですべての.msiファイルを見つけてインストールできました。
foreach($_msiFiles in
($_msiFiles = Get-ChildItem $_Source -Recurse | Where{$_.Extension -eq ".msi"} |
Where-Object {!($_.psiscontainter)} | Select-Object -ExpandProperty FullName))
{
msiexec /i $_msiFiles /passive
}
これにスイッチやその他のパラメータを追加するだけです。 – Brettski