powershell

What are your favorite Powershell Cmdlets?

I just found /n softwares free Powershell NetCmdlets, and after playing with them I love the functionality they bring to the command line. So it raises the question what are your favorite Cmdlets, and how do you use them? ...

How do you use PowerShell?

Windows PowerShell came out last year and got great reviews from many .net bloggers (Hanselman comes to mind). It seemed to be touted as a great new utility that somehow made everything that you would ever do on the command line easier, and integrated with .Net. However, the more I read about it, the more it seems to be a tool that is gr...

Can I copy files to a Network Place from a script or the command line?

Is it possible, in Windows XP, to copy files to a Network Place from the command line, a batch file or, even better, a PowerShell script? What sent me down this road of research was trying to publish files to a WSS 3.0 document library from a user's machine. I can't map a drive to the library in question because the WSS site is only ava...

Why don't my powershell scripts run?

I wrote a simple batch file as a powershell script, getting errors when they run. its in a scripts directory in my path. Cannot be loaded because the execution of scripts is disabled on this system. please see "get-help about-signing". I looked in the help, but its less than helpful. @Matt HAmilton's answer FTW ...

How do you impersonate an Active Directory user in Powershell?

I'm trying to run powershell commands through a web interface (ASP.NET/C#) in order to create mailboxes/etc on Exchange 2007. When I run the page using Visual Studio (Cassini), the page loads up correctly. However, when I run it on IIS (v5.1), I get the error "unknown user name or bad password". The biggest problem that I noticed was tha...

Powershell's Invoke-Expression missing param

I thought that I had the latest CTP of Powershell 2 but when I try the command: invoke-expression –computername Server01 –command 'get-process powershell' I get an error message: A parameter cannot be found that matches parameter name 'computername'. So the question is: How can I tell which version of PowerShell I have installed? And w...

quoting System.DirectoryServices.ResultPropertyCollection

I'm missing something here: $objSearcher = New-Object System.DirectoryServices.DirectorySearcher $objSearcher.SearchRoot = New-Object System.DirectoryServices.DirectoryEntry $objSearcher.Filter = ("(objectclass=computer)") $computers = $objSearcher.findall() So the question is why do the two following outputs differ? $computers...

How do I make Powershell run a batch file and then stay open?

For example; with the old command prompt it would be: cmd.exe /k mybatchfile.bat Thanks. John. ...

PowerShell FINDSTR eqivalent?

What's the DOS FINDSTR equivalent for PowerShell? I need to search a bunch of log files for "ERROR". ...

PowerShell - how do I do a string replacement in a function?

How do I convert function input parameters to the right type? I want to return a string that has part of the URL passed into it removed. This works but uses a hard coded string: function CleanUrl($input) { $x = "http://google.com".Replace("http://", "") return $x } $SiteName = CleanUrl($HostHeader) echo $SiteName This fails:...

PowerShell App.Config

Has anyone worked out how to get PowerShell to use app.config files? I have a couple of .NET DLL's I'd like to use in one of my scripts but they expect their own config sections to be present in app.config/web.config. @Steve/Sam: I had a horrible feeling those were going to be the answers. Thanks Kev ...

How do I compare two arrays of DataRow objects in PowerShell?

I have two arrays of System.Data.DataRow objects which I want to compare. The rows have two columns A and B. Column A is a key and I want to find out which rows have had their B column changed and which rows have been added or deleted. How do I do this in PowerShell? ...

execute shortcuts like programs in powershell

Example: You have a shortcut s to SomeProgram in the current directory. In cmd.exe, you can type s and it will launch the program. In PowerShell, typing s gives: The term 's' is not recognized as a cmdlet, function, operable program, or script file. Verify the term and try again. If you type s.lnk or SomeProgram, it runs the prog...

PowerShell - How do I pass string parameters correctly?

Is there documentation or an article on the rules for passing strings into PowerShell functions? I just trying to do some string concatenation/formatting, but it's putting all the parameters into the first placeholder. Code function CreateAppPoolScript([string]$AppPoolName, [string]$AppPoolUser, [string]$AppPoolPass) { # Command to...

Accessing .NET components from Powershell

I want to use Powershell to write some utilities, leveraging our own .NET components to handle the actual work. This is in place of writing a small console app to tie the calls together. My question is where I would find a good source of documentation or tutorial material to help me fast track this? ...

Set up PowerShell Script for Automatic Execution

I have a few lines of PowerShell code that I would like to use as an automated script. The way I would like it to be able to work is to be able to call it using one of the following options: One command line that opens PowerShell, executes script and closes PowerShell (this would be used for a global build-routine) A file that I can do...

get file version in powershell

How can you get the version information from a .dll or .exe file in PowerShell? Specifically interested in File Version, though other version info (i.e. Company, Language, Product Name, etc) would be helpful as well. ...

How to get started with PowerShell?

I played with one of the early beta's of Powershell V1, but haven't used it since it went "gold". What is the best way to get started using Powershell? Which version of Powershell should I be using (V1.0 vs 2.0 CTP's)? What are you using Powershell for? Are there any tools that make using Powershell easier (i.e. development environments)...

Windows 2003 Scheduled Task Cmdlet (v 1.0)

Does anyone know of a powershell cmdlet out there for automating task scheduler in XP/2003? If you've ever tried to work w/ schtasks you know it's pretty painful. ...

Windows Powershell book - any good experiences?

Hi betatester-fellows :) ! I'm currently looking for a recommendable book about psh which seems to be very a feature rich new shell. Therefore I'm looking for some kind of pragmatic documentation, aiming a little deeper. I'm using Unix Shells like zsh since ages, but Scripting on MS was never very effective. Until now. I'm interested in...