Questions tagged [powershell]
PowerShell is a cross-platform command line and scripting utility from Microsoft. Use this tag for questions about writing and executing PowerShell scripts ONLY. Programming questions specific to the cross-platform version PowerShell Core (Windows, macOS, and Linux) should be tagged [powershell-core]. Questions about system administration should be asked on Super User or Server Fault.
powershell
118,120
questions
27
votes
8
answers
24k
views
Is PowerShell a good upgrade for a batch file?
I package our server releases into zip files using a batch file (Windows), running the command-line version of WinZip. Previously we did this sort of thing "by hand" but I developed the process of ...
12
votes
5
answers
12k
views
How to run MSBuild from Powershell without spawning msbuild.exe process?
I am considering running MSBuild from a Powershell script by tapping directly to the MSBuild assemblies (as opposed to looking up MSBuild install path and starting msbuild.exe as a child process).
...
6
votes
7
answers
791
views
Command line (or equivalent) tools for .NET development
Spending most of my time in Visual Studio and using all the IDE tools, I wish I could spend more time using either of the following.
The Command Window in Visual Studio
CMD.EXE
Cygwin, MinGW...
...
30
votes
8
answers
55k
views
How do I change a file's attribute using Powershell?
I have a Powershell script that copies files from one location to another. Once the copy is complete I want to clear the Archive attribute on the files in the source location that have been copied.
...
2
votes
3
answers
6k
views
Problems with Excel automation in PowerShell
I’m trying to automate the refreshing of data in my Excel Reports. Here the script:
$ExcelApp = new-object -ComObject Excel.Application
$ExcelApp.Visible = $false
$ExcelApp.DisplayAlerts = $false
$...
5
votes
5
answers
56k
views
How can I get Windows Powershell Get-ItemProperty to only show the property I want?
When using powershell, sometimes I want to only display for example the name or fullname of a file.
From what I can gather, the way to do this is by using Get-ItemProperty (alias of gp) and passing -n ...
2
votes
2
answers
1k
views
How do I efficiently transform a series of strings in powershell?
Suppose I have a large number of strings formatted something like:
<tag>blah blahXXXXXblah blah</tag>
I want to transform these strings into something like:
blah blahZZZZZblah blah
on ...
5
votes
2
answers
8k
views
PowerShell Windows Installer Com Object
I'm trying to modify the contents of an MSI file using Powershell. To do so I create an instance of a WindowsInstaller.Installer then use $installer.OpenDatabase and $database.OpenView. Similar ...
2
votes
3
answers
2k
views
Custom read-host dialog for PowerShell 2 CTP3 ISE
Is it possible to hook a custom dialog into the new PowerShell ISE (Integrated Scripting Environment) that replaces the existing .NET WinForms dialog. I am talking about the dialog that the Read-Host ...
3
votes
1
answer
839
views
Confusing evaluation of $args in PowerShell
The $args variable should, by definition, contain all arguments passed to a script function. However if I construct a pipeline inside my function, the $args variable evaluates to null. Anyone knows ...
10
votes
4
answers
16k
views
How to expand a PowerShell array when passing it to a function
I have two PowerShell functions, the first of which invokes the second. They both take N arguments, and one of them is defined to simply add a flag and invoke the other. Here are example definitions:
...
2
votes
3
answers
2k
views
Powershell Remote Commands
I'm trying to run the get-service command on a remote machine in powershell. After doing some research, it appears this is only possilbe n powershell 2 CTP, which I cannot use as I need to use the ...
10
votes
2
answers
18k
views
How to escape command line arguments on PowerShell?
It appears that I can escape command line arguments using single or double quotes:
PS C:\> echo Hello World
Hello
World
PS C:\> echo 'Hello World'
Hello World
PS C:\> echo "Hello World"
...
11
votes
2
answers
2k
views
Powershell cmdlets development best practices
I'm currently putting together some Powershell cmdlets. Building them is easy enough but I don't know if I'm building them in an acceptable manner (so to speak).
Are there any guidelines/best ...
4
votes
5
answers
19k
views
How can I retrieve an assembly's qualified type name?
How can I generate a assembly qualified type name?
For an example, when configuring a membership provider, I would have to provide a assembly qualified type name for "SqlMembershipProvider" (in this ...