powershell

Using PowerShell to add an extension to files

I have a directory of files that I'd like to append file extension to as long as they don't have an existing, specified extension. So add .txt to all file names that don't end in .xyz. PowerShell seems like a good candidate for this, but I don't know anything about it. How would I go about it? ...

How can I mute/unmute my sound from PowerShell

Trying to write a PowerShell cmdlet that will mute the sound at start, unless already muted, and un-mute it at the end (only if it wasn't muted to begin with). Couldn't find any PoweShell or WMI object I could use. I was toying with using Win32 functions like auxGetVolume or auxSetVolume, but couldn't quite get it to work (how to read th...

Why would I choose Powershell over WMI to develop management interfaces?

We are discussing development of an improved management infrastructure for our distributed system. We use COM, web services and .NET components. Since we're based on Microsoft Windows Server XP/2003, I guess, we basically have two options: Powershell cmdlets WMI classes using System.Management and WMI providers for native code (class, ...

Creating an IIS 6.0 Application Pool using Powershell

How do I create an Application Pool on IIS 6.0 using a Powershell script? This is what I have come up with so far: $appPool = [wmiclass] "root\MicrosoftIISv2:IIsApplicationPool" Thanks ...

What's the best way to automate secure FTP in PowerShell?

I'd like to automate the FTP download of a database backup file using PowerShell. The file name includes the date so I can't just run the same FTP script every day. Is there a clean way to do this built into PowerShell or using the .Net framework? UPDATE I forgot to mention that this is a through a secure FTP session. ...

Can we see the source code for PowerShell cmdlets?

Hi, I'm learning some PowerShell. Is it possible to see the source code for a built-in cmdlet like Get-ChildItem? ...

Anyone found a PowerShell Syntax highlighting or IntelliSense plugin for Visual Studio?

Has anyone found a plugin for Visual Studio to allow for PowerShell syntax highlighting or IntelliSense? If not, does anyone have any idea why not? I keep hoping someone else with copious free time would have tackled this by now. I have hope since other folks have managed to take the limited documentation and build custom IntelliSense p...

"File -X: does not exist" message from ipy.exe in Windows PowerShell

If I type this line in an MS-DOS command prompt window: ipy -X:ColorfulConsole IronPython starts up as expected with the colorful console option enabled. However, if I type the same line in Windows PowerShell I get the message: File -X: does not exist Can someone explain what I'm doing wrong? ...

"Extend my Windows desktop onto this monitor." programatically

I would like to be able to do "Extend my Windows desktop onto this monitor" via code. A PowerShell script would be idea. I have googled around a far amount and WMI seems the way forward but as I have zero knowledge in WMI I thought I would try here. Hope someone can help! Cheers, Zi ...

How do I reference files with brackets in the name

Create a file called Valid[File].txt and stick some text in it. Start powershell and go to the directory. gc Valid[File].txt should display the value in the file. It returns blank. If you use tab auto-completion it escapes the name: gc 'Valid[File].txt' but still returns nothing. How do I reference files with brackets in their na...

Is it possible to terminate or stop a PowerShell pipeline from within a filter

I have written a simple PowerShell filter that pushes the current object down the pipeline if its date is between the specified begin and end date. The objects coming down the pipeline are always in ascending date order so as soon as the date exceeds the specified end date I know my work is done and I would like to let tell the pipeline...

Importing "libraries" in powershell

I'm finding myself writing a bunch of related functions dealing with different nouns (clusters, sql servers, servers in general, files, etc.) and put each of these groups of functions in separate files (say cluster_utils.ps1, for example). I want to be able to "import" some of these libraries in my profile and others in my powershell se...

What are some good powershell script repositories?

I know of a couple, and I've seen several blogs which include scripts sporadically, but I was wondering if there were any other good places to look. http://powershell.com/cs/media/13/default.aspx http://powershellcommunity.org/Scripts.aspx ...

PowerShell yielding to OS in tight loops

I've previously encountered the suggestion to call System.Threading.Thread.Sleep(0); in tights loops in C# to prevent CPU hogging and used it to good effect. I have a PowerShell script that has a tight loop and I'm wondering whether I should be calling [Thread]::Sleep(0) or Start-Sleep 0 or whether the PS engine will yield for me occasi...

Apple DMG files over FTP are getting corrupted why?

I am trying to FTP some apple DMG files, if we do it by hand through Safari or IE it ends up at the destination just fine and uncorrupted. However, if I use a freeware FTP client that we had been using with great success for zip's and exe's or if I use a Powershell script I finished off (adapted from another stackover flow's question's a...

Stress testing a web service method with Powershell

I want to stress test a web service method by calling it several thousand times in quick succession. The method has a single string parameter that I will vary on each call. I'm planning on writing a Powershell script to loop and call this method a number of times. Is there a better way to do this? ...

How do I get PowerShell to grab a logfile when it overflows?

I am using Powershell PSeventing plugin but have had no luck so far finding an event that triggers when an event log is full. I am looking everywhere MSDN .net events I know it has to do with maximum event log size but I can't find that trigger and I'm not sure how to get PSeventing to make thing happen. Can anyone help me. Thank in a...

Change IIS Site Home Directory w/ Powershell

I can query the AD and find all the IIS sites and their virtual directories, now I need to be able to update those home directories and save the changes. After I fetch the directory entry I can display the site path using $site.Path, however setting it doesn't seem to have any effect. It never changes the actual stored path. I have ...

In Powershell how can I convert a string with a trailing 'sign' to a number?

I need to convert strings with optional trailing signs into actual numbers using Powershell. Possible strings are: 1000- 323+ 456 I'm trying to use System.Int.TryParse with a NumberStyles of AllowTrailingSign, but I can't work out how to make System.Globalization.NumberStyles available to Powershell. ...

How do you start a program stored on a UNC share from the command line with parameters?

There's an in-house program we use and it's stored on a UNC share so that updates are transparent. I'd like to supply it some command line parameters like so: \\server\share\in_house_thingy.exe myusername mypassword But I can't seem to get it to work in either CMD or PowerShell or via a shortcut. Anyone got any ideas? ...