powershell

How to batch update multiple workitems in TFS

I need to update same field to same value for hundreds of workitems in TFS. Is there any way to do it in a batch instead of updating them manually one by one? ...

Powershell 2.0 out-file formatting nightmare...

How can I get Powershell to output a file IDENTICAL to the file produced by the following command? dir /s /b /a-d *.* > C:\files.txt should be easy, right?!! EDIT: I found ps was truncating the output based on the screen buffer width. Fix that with format-table and it pads with spaces... try format-list and you get property headings.....

catching return code of a command with "invoke-command" - Powershell 2

Hi, I am using "invoke-command" to execute a script on a remote machine. invoke-command -computername <server_name> -scriptblock {command to execute the script} My script returns "-1" when there are any errors. So, I wanted to ensure that script has executed successfully by checking the return code. I tried as follows. $code = invok...

How to redirect the output of a PowerShell to a file during its execution

I have a Powershell script for which I would like to redirect the output to a file. The problem is that I cannot change the way this script is called. So I cannot do: .\MyScript.ps1 > output.txt How to redirect the output of a Powershell script during its execution? Thanks! ...

How to start SQL Server agent jobs automatically

Hello everyone, I am writing PowerShell scripts to control SQL Server agent start/stop to ensure all the contained jobs runs according to defined schedule. I want to make sure that the only thing I need to do is to start the SQL Server Agent Windows Service, and then all the contained SQL Server Jobs will run automatically according to ...

Can I query Changesets via tfpt.exe, tf.exe, or via the TFS API (from powershell)?

I know how to query workitems, although I haven't been very successful finding info on the WIQL. There's one basic example that seems to get repeated everywhere. I'd like to be able to query changesets. Can I do it with tf.exe, tfpt.exe, or.. ? ...

how to set a Windows Service to be auto-restart in PowerShell?

Hello everyone, If I know a service name, and have enough permission. My question is how to set a Windows Service to be auto-restart in PowerShell? I am using PowerShell 1.0, OS is Windows Server 2003. thanks in advance, George ...

Error stopping a Windows Service

Hello everyone, I am using PowerShell 1.0 on Windows Server 2003 x64. When executing the following statement, there is error below. Not every time this error occurs, and if this error occurs and I execute this command again, there is no error again! It is so weird. Any ideas what is wrong? Stop-Service "SQLServerAgent" -Force -ErrorAct...

How do I find out what volume a given NTFS path is on when using mount points?

I have an Exchange server with lots of mountpoints. Given the path to the database files is there a way to find out what volume they are on? The problem is that they are typically not at the volume mount point, but further down the tree. I'm using Powershell, so I need a solution preferably using WMI but could also use any .NET or COM...

PowerShell and WPF GUI freeze

I have a PowerShell function to look in a directory for zip files, extract it, and rename the files. The function also changes the status bar item to update what file it is on. I noticed that when this runs the GUI would freeze. How can I get the function run and update the GUI without it freezing? ...

problem with .Net xml importnode

Hi, Im trying to construct a powershell script that uses some XML. I have a XML document where I try to add some values with email addresses. The finished xml document should have this format: (I'm only showing the relevant part of the xml here) <emailAddresses> <value>[email protected]</value> <value>[email protected]</value> <va...

Capturing Powershell output in C# after Pipeline.Invoke throws

I'm running a Powershell test script from a C# application. The script can fail due to a bad cmdlet which causes pipe.Invoke() to throw an exception. I'm able to capture all the information I need about the exception, but I'd like to be able to display the script's output up to that point. I haven't had any luck since results appears to...

Automate deployment of XMLA / documentation on Microsoft.AnalysisServices.Xmla

I'm looking to automate the deployment of XMLA scripts. I've come across an article that gives a small demo, but I'm hoping to find more info. Specifically, where is the documentation for Microsoft.AnalysisServices.Xmla.XmlaClient and what is the best approach for overridding the database and connection values that are embedded in the X...

Is there a simple way to pass specific *named* powershell parameters through directly to a called function

I am sure I read somewhere that there is an easy way to pass named parameters from a calling function to a called function without explicitly naming and specifying each parameter. This is more than just reusing the position; I'm interested in the case where the name of the passed parameters is the same in some cases, but not in others. ...

Run a function on each element of a list in powershell

I have a directory full of file pairs. Each pair of files have the same name with the extensions of mp3 and cdg (karaoke files!). I would like to use powershell to get the list of all distinct file names with no extensions I've gotten as far as: dir -recurse -filter "*.mp3" | select-object Name | sort But I can't quite figure out h...

How can I determine from a PowerShell script in runtime in which host it is running?

I try to figure out whether my script is running in PowerShell.exe or in the ISE. If I am running in PowerShell.exe then I would like to change the size of the console window, but I don't want to impact the ISE, if I don't. ...

How to monitor Windows Dialog?

I am looking for a way to monitor Windows dialog during a MSI deployment. Here is my situation: we have machines deploying daily MSIs and once in a while, one of them fail and shows a Windows dialog with an error message. I am trying to find a way to write a script (maybe in Powershell) which will run every minutes and look for a Window...

In Windows PowerShell, How Can You Set the Maximum CPU % for the Script to Use?

I am looking to limit the percentage of the CPU time used by a PowerShell process to a certain number -- for the sake of argument, let's imagine it to be 13%. Other options that are not precisely what I need: 1) Setting priority. 2) Setting CPU affinity. Basically, we have monitoring software which complains if the total CPU usage gets...

Why do Windows consoles lose command-line history (up arrow) after a time?

It seems random: after some amount of time / usage of any console I use on Windows Vista, I lose the ability to use the command-line history (or command buffer, if you prefer...), and hitting the up or down arrow no longer does anything at all, meaning there are essentially 0 items available in the history. I've seen this behavior in Cy...

Deploy Registry Change

What is the best way to deploy a HKCU registry change for anyone who logs onto the machine. Someone mentioned to me Active Setup...but I am not sure. ...