Solved

Initiating WMIC from within a Powershell Script

Posted on 2010-11-26
2
653 Views
Last Modified: 2012-05-10
OK so here's my script thusfar:

#script to remotely install software"

#prompt for destination computer name"
$computername = Read-host "Enter the computer name."

#prompt for software app name"
#$product = Read-Host "Type the application name here."

#prompt for installer MSI"
$msiPath = Read-Host "Type the complete path to the installer MSI file"
#yes/no prompt to continue"
	
#$yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes",""
#$no = New-Object System.Management.Automation.Host.ChoiceDescription "&No",""
#$choices = [System.Management.Automation.Host.ChoiceDescription[]]($yes,$no)
#$caption = "Warning!"
#$message = "Do you want to proceed"
#$result = $Host.UI.PromptForChoice($caption,$message,$choices,0)
#if($result -eq 0) { Write-Host "You answered YES" }
#if($result -eq 1) { Write-Host "You answered NO" }
wmic
/node:$computername product call install true,"","$msiPath"

Open in new window


However tests runs show that once the script hits the WMIC line it just sits there.  So I figure I'm missing something, just no clue what it is.

the commented out section was me trying to include a Yes/No prompt.. disregard please.
0
Comment
Question by:Ben Hart
2 Comments
 
LVL 12

Accepted Solution

by:
larsrohr earned 250 total points
ID: 34220636
I'd say you need lines 21 and 22 concatenated:
wmic /node:$computername product call install true,"","$msiPath"

Putting "wmic" alone on a line simply opens up the wmic prompt, and you have no way to exit from that.
0
 
LVL 14

Author Comment

by:Ben Hart
ID: 34222232
/sigh

Feel like a tard hat.  thanks brah.
0

Featured Post

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will help you understand what HashTables are and how to use them in PowerShell.
In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question