powershell

How do I use PowerShell to stop and start a clustered "Generic Service"?

How do I use PowerShell to stop and start a "Generic Service" as seen in the Microsoft "Cluster Administrator" software? ...

Is PowerShell a strongly typed language?

PowerShell is definitely in the category of dynamic languages, but would it be considered strongly typed? ...

Using Powershell to access IIS logs?

I know you can use powershell to make things like the registry a drive letter. There are other objects in powershell to treat other objects in this way. Does anyone know of any cmd-lets to access IIS logs in this manner? ...

What is the meaning of Powershell's Copy-Item's -container argument?

I am writing a script for MS PowerShell. This script uses the Copy-Item command. One of the optional arguments to this command is "-container". The documentation for the argument states that specifying this argument "Preserves container objects during the copy operation." This is all well and good, for I would be the last person to wa...

What's in your Powershell profile.ps1file?

What essential things (functions, aliases, start up scripts) do you have in your profile? ...

How do I call a Win32 Function in PowerShell 1.0 using P/Invoke?

There are many scenarios where it would be useful to call a Win32 function or some other DLL from a PowerShell script. to Given the following function signature: bool MyFunction( char* buffer, int* bufferSize ) I hear there is something that makes this easier in PowerShell CTP 2, but I'm curious how this is best done in PowerShell 1.0...

Powershell script to download file, having trouble setting up a secure connection

I'm making an automated script to read a list from a site posting the latest compiled code. That's the part I've already figured out. The next part of the script is to grab that compiled code from a server with an Untrusted Cert. This is how I'm going about grabbing the file: $web = new-object System.Net.WebClient $web.DownloadFile("h...

PowerShell functions return behavior

I am seeing some rather weird behavior with PowerShell, it looks like custom functions might need a "parenthesis wrapper" to evaluate as you might expect them. Given a simple PowerShell function: function Return-True { return $true } and then some sample code to invoke it: PS C:\> Return-True True PS C:\> Return-True -eq $false True ...

Waiting for user input with a timeout

I have searched but apparently my google foo is weak. What I need is a way to prompt for user input in the console and have the request time out after a period of time and continue executing the script if no input comes in. As near as I can tell, Read-Host does not provide this functionality. Neither does $host.UI.PromptForChoice() nor d...

Customizing PowerShell Prompt - Equivalent to CMD's $M$P$_$+$G?

Hi all! I've started to "play around" with PowerShell and am trying to get it to "behave". One of the things I'd like to do is to customize the PROMPT to be "similar" to what "$M$P$_$+$G" do on MS-Dos: A quick rundown of what these do: Character| Description $m The remote name associated with the current drive letter or the empty s...

In PowerShell, how can I determine if the current drive is a networked drive or not?

I need to know, from within Powershell, if the current drive is a mapped drive or not. Unfortunately, Get-PSDrive is not working "as expected": PS:24 H:\temp >get-psdrive h Name Provider Root CurrentLocation ---- -------- ---- --------------- H FileSystem H:\ temp but in MS-Dos "...

In PowerShell, how can I determine the root of a drive (supposing it's a networked drive)

In PowerShell, even if it's possible to know if a drive is a network drive: see http://stackoverflow.com/questions/158359/in-powershell-how-can-i-determine-if-the-current-drive-is-a-networked-drive-or When I try to get the "root" of the drive, I get back the drive letter. The setup: MS-Dos "net use" shows that H: is really a mapped net...

How can I audit passwords in powershell?

I'd like to enumerate domain accounts and try authenticating as each with a limited set of passwords. The issue is that I can't find any way to attempt to validate credentials without "doing" something (e.g. querying wmi with impersonation) which isn't useful as the account may or may not have the ability to connect via wmi in the firs...

Best IDE for Powershell?

What are the different IDE's for PowerShell? Which is the best? ...

Powershell: Run a program in a foreach.

I'm trying to get this simple Powershell script working but I think something is fundamentally wrong ;-) ls | foreach { "C:\Working\tools\custom-tool.exe" $_ } I basically want to get files in a directory and pass them one by one as arguments to the custom tool. ...

RPC_E_SERVERCALL_RETRYLATER during powershell automation

I'm using PowersHell to automate iTunes but find the error handling / waiting for com objects handling to be less than optimal. Example code #Cause an RPC error $iTunes = New-Object -ComObject iTunes.Application $LibrarySource = $iTunes.LibrarySource # Get "playlist" objects for main sections foreach ($PList in $LibrarySource.Playlists...

PowerShell: CLI or GUI - which do you need or prefer?

PowerShell v1.0 is obviously a console based administrative shell. It doesn't really require a GUI interface. If one is required, like the Exchange 2007 management GUI, it is built on top of PowerShell. You can create your own GUI using Windows Forms in a PowerShell script. My question is, "What sort of PowerShell scripts or management t...

Monitoring Windows directory size

I'm looking for something that will monitor Windows directories for size and file count over time. I'm talking about a handful of servers and a few thousand folders (millions of files). Requirements: Notification on X increase in size over Y time Notification on X increase in file count over Y time Historical graphing (or at least sav...

How to start PowerShell from Windows Explorer?

Does anyone know of a way to start PowerShell in a specific folder from Windows Explorer, e.g. to right-click in a folder and have an option like "Open PowerShell in this Folder". It's really annoying to have to change directories to my project folder the first time I run MSBuild every day. ...

Powershell Generic Collections

I have been pushing into the .Net framework in powershell and I have hit something that I don't understand. This works fine: 13# $foo = New-Object "System.Collections.Generic.Dictionary``2[System.String,System.String]" 14# $foo.Add("FOO", "BAR") 15# $foo Key Value --- ...