Solved

Initiating WMIC from within a Powershell Script

Posted on 2010-11-26
2
645 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

How to sign a powershell script so you can prevent tampering, and only allow users to run authorised Powershell scripts
Synchronize a new Active Directory domain with an existing Office 365 tenant
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

707 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now