?
Solved

Run an executable with a passed variable using PowerShell

Posted on 2013-01-22
3
Medium Priority
?
257 Views
Last Modified: 2013-01-30
Hello. I have a command that I would like to run. The command requires a parameter. I have added the parameter to a text file. Using PowerShell, I know how to read the text file and output what is it in but but cannot figure out how to pass it to the executable. Below is the command and my script so far. Could anyone point me in the right direction for executing the command with the parameter using PowerShell? Thank you for any assistance.

The text file contains Windows Features that I would like to remove online using DISM. It contains items like MediaCenter, Chess, etc.

Command
DISM /online /Disable-Feature /FeatureName:<<parameter from text file>>

Script so far
$Cleanup = "E:\Features\Removal.txt"
Get-Content $Cleanup | Foreach-Object {Write-Host $_}
0
Comment
Question by:Lorrec
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 14

Accepted Solution

by:
athomsfere earned 2000 total points
ID: 38806434
Here is a function in Powershell I use for SQL installs.

function sql08R2($a)
	{
	Write-Host $a
	$Installer = "R:\MS SQL Server 2008 R2 Standard\setup.exe"
	$Argus = '/Q /ConfigurationFile="R:\2008R2Conf.ini"'
	Write-Host $Argus
	Start-Process -FilePath $Installer -ArgumentList $Argus -Wait -PassThru
	Write-Host "2008 R2 Installed"
	}

Open in new window


The Start-Process is what calls the application, -wait tells the script to not move on until the install is done.
0
 
LVL 70

Expert Comment

by:Qlemo
ID: 38806591
Get-Content $Cleanup |
  Foreach-Object { DISM /online /Disable-Feature /FeatureName:$_ }

Open in new window

should do that.
0
 

Author Closing Comment

by:Lorrec
ID: 38835185
Thank you for the assistance.
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
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…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

770 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