powershell

How can I use PowerShell to set the default document in IIS?

I'm configuring a web site using PowerShell and I want to set the default document. How do I do this? ...

What powershell script can do and what we can NOT do with it?

I'm thinking to learn Powershell. Can somebody tell me what Powershel is good at and what's its limitation before I start? Thanks a lot! ...

How to put a header to csv file generated by Powershell script

Hi, I got this Powershell script that queries users that have not changed their password for 24 hours. The query redirects the output to csv file. Below are the Powershell script and batch script: Powershell script: $root = [ADSI]'' $searcher = new-object System.DirectoryServices.DirectorySearcher($root) $searcher.filter = "(&(objectC...

install/uninstall a Windows Service

Hello everyone, I have created a Windows Service project using VSTS 2008 Windows Service type project and now I want to write scripts to install/uninstall it using PowerShell. Any reference samples or documents? thanks in advance, George ...

Equivalent to C#'s "using" keyword in powershell?

When I use another object in the .net-Framework in C# I can save a lot of typing by using the using directive. using FooCompany.Bar.Qux.Assembly.With.Ridiculous.Long.Namespace.I.Really.Mean.It; ... var blurb = new Thingamabob(); ... So is there a way in Powershell to do something similiar? I'm accessing a lot of .net objects and...

powershell search for docs created by user?

Can I search a drive to show all documents that were created by a particular user? I figured powershell is the way to go...but perhaps another approach is possible? Basically, I want to search a drive and find all *.doc or *.docx files and access the word properties to view who created the file (author). ...

Need a PowerShell script that copies files from the current dir that the script is run from to another location

Hi all, I have a pretty basic PowerShell script that I need help with. This is my first time even attempting to script so bare with me. I work for a software development and they have asked me to write a script that they can package in with their build updates. Basically they will complete a build that get's dropped to a folder (say \se...

How do I set up TFS PowerShell Snapin

I have installed TFS Power Tools and I am trying to use the powershell snapin, but I can't figure out how to set it up. When I look in the install folder, I only see the following 5 dlls. Microsoft.TeamFoundation.PowerToys.Client.dll Microsoft.TeamFoundation.PowerToys.Common.dll Microsoft.TeamFoundation.PowerToys.Controls.dll Microsoft...

Copy Folder/File wiithout modifying attributes?

Is it possible to copy a file or a folder from one location to another without modifying its attribute data? For example if I have a folder on a network drive and it was created on 2/3/2007 and I want to copy it to my c: drive .. but leave the date/time stamp as 2/3/2007...is that possible? ...

Windows Network adaptor disable enable via Powershell

My network card is rubbish and until I get a new one I need a quickfix. My idea was to have a program ping my router and when the ping failed 3 or 4 times, it would reset the network adaptor for my wifi card, however I do not know the command line commands to do this! I found the following in a stackoverflow question: $adaptor = Get-Wm...

Enable/Disable a mounted drive using a powershell script

I have a disk drive that is mounted by an API. The drive is mounted but defaults to disabled. Does anyone know how to use powershell script to enable the drive? (Windows Server 2008, Powershell 1.0) ...

How to encode Unicode character codes in a Powershell string literal?

How can I encode the Unicode character U+0048 (H), say, in a Powershell string? In C# I would just do this: "\u0048", but that doesn't appear to work in Powershell. ...

How do I insert data into a Postgres table using PowerShell or VBScript?

I need to periodically query the event logs on a handful of servers and insert specific events into a Postgres table. I am having trouble figuring out how I can insert data into a table via ODBC using PowerShell and/or VBScript. I'm reasonably familiar with both VBScript and PowerShell generally, and I can craft a SQL UPDATE statement t...

Why does using a pipe not work in powershell?

I'm trying to execute the following line: exit | sqlplus username/password@sid @test.sql Works great from cmd but in powershell I get "An empty pipe element is not permitted" Why is this and how do I fix it? ...

Is there a way to wordwrap results of a Powershell cmdlet?

Simple (probably stupid) question. I'm a Powershell novice and am mainly using it to instantiate managed libraries so I don't have to write little apps when I need to use members from them. Some of these libraries are old and have methods with long, painful signatures. Using get-member after instantiating with new-object, I've often r...

What are good guidelines for naming PowerShell verbs?

I'm early on in my PowerShell learning, and I'm wondering if there are some good guidelines for verbs in Posh for cmdlets (or advanced functions, whatever they're called in CTP3). If I do a get-verb I can see the lot of them. But I'm still not sure how I should lay out my modules. Here's the example I'm running into right now. I have a...

creat event source issue

Hello everyone, I am using Windows Server 2003 x64 + VSTS 2008 + .Net 3.5 + C#, the API EventLog.CreateEventSource has two parameters, source and logName. I have two questions, How to call function EventLog.CreateEventSource from PowerShell? What are the meanings of parameter source and logName? How their values are reflected in Wind...

Using PowerShell to download XML, and save as CSV file?

I'm fairly new to PowerShell, but have a strong C# background. The task I'm trying to accomplish is to download some XML, and then save some of the elements from the XML file in a .csv file. I don't need all the elements from the XML, just a few items. The XML looks something like this: <result> <case> <InputData> <Id>1</I...

Is there any way to terminate a hung process in Powershell?

I'm using Powershell to test a COM object method call. Due to poor design/coding/everything, this COM object method simply hangs when it errors. My default instinct is to control+c out of it, but this does not work. Do I have to kill Powershell to kill a hung COM method call? Thanks in advance. ...

Unable to get members of Universal Distribution List using Powershell

I am trying to write a script to list out all members of a "Universal Distribution List" using Powershell. However I keep getting an empty result set back. When I run the following command against a "Global Distribution List" it works fine and I can see who belongs to it. dsquery group -name "SomeGroup" | dsget group -members -expand ...