powershell

PowerShell Script to Find and Replace for all Files with a Specific Extension

I have several configuration files on Windows Server 2008 nested like such: C:\Projects\Project_1\project1.config C:\Projects\Project_2\project2.config In my configuration I need to do a string replace like such: <add key="Environment" value="Dev"/> will become: <add key="Environment" value="Demo"/> I thought about using batch ...

POWERSHELL; Recursive Get-Member for Com Object

I have a statement "New-Object -com Indesign.Application.Cs5 | Get-Member" It works as expected for the top level. How would one recurse the entire object tree and output results in a readable/spreadsheet format (if possible). ...

How to open document that contains AutoOpen macro with PowerShell?

My current PowerShell script: $document = "C:\\test.doc" $word = new-object -comobject word.application $word.Visible = $false $word.DisplayAlerts = "wdAlertsNone" $word.AutomationSecurity = "msoAutomationSecurityForceDisable" $doc = $word.Documents.Open($document) $word.ActivePrinter = "\\http://ptr-server:631\pdf-printer" $background ...

PowerShell; Use Get-Member to Self Document Nested COM Object

Anyone know how to use Get-Member to Recursively dump to a text file The entire properties|methods tree of a COM object? (The Output formatting of Get-Object is fine) Instead of giving me only the top level as in this example; New-Object -com AutoItX3.Control | Get-Member I need it to recurse the entire object to return results. If Th...

Cannot load Windows PowerShell snap-in Microsoft.PowerShell.Host

Hi everyone, I'm attempting to invoke Windows Powershell cmdlets via Visual Studio .NET. However, I'm getting the exception shown below when I try to call a function.The Microsoft.PowerShell.ConsoleHost.dll wasn't initially in that path so I copied it over from another location. Is this the right way of installing a snap-in? It still sp...

PowerShell - Parameter Value Tab Expansion for Enum types

Is it possible to implement parameter value tab expansion for enum parameter types? Creating a binary cmdlet with parameter definition: [Parameter] public SomeEnum Type {get;set;} Is there some way to type: Add-MyThing -Type S<tab> To get: Add-MyThing -Type SomeEnumValue Where: public enum SomeEnum { SomeEnumValue, S...

Is there a way in Powershell to query the object Property Page Details

Is there a way in Powershell to query the object Property Page Details to verify if the Copyright, Product name and File version are not empty. I want to be able to query this info when I'm looking for viruses ...

Ensuring an assembly is called via a specified assembly

Is there any built in functionality to determine if an assembly is being called from a particular assembly? I have assembly A which references assembly B. Assembly A exposes PowerShell cmdlets and outputs types that are found within B. Certain methods and properties with in types of exposed by B are of interest to types in assembly A b...

Powershell Script to output Installed Programs

I'd like to do this using the win32_product wmi class. I need the script to simply count the number of products installed and also output the time taken to execute the script. What I have atm doesn't seem to work correctly: $count = 0 $products = get-wmiobject -class "Win32_Product" foreach ($product in $products) { ...

Which w3wp.exe process belongs to which App Pool in IIS6 (with powershell)

to date, I use this tool to tell which w3wp belongs to which App Pool c:\windows\system32\cscript iisapp.vbs How can I extract the same information with Powershell? Or maybe, with more informative results. Thanks :) ...

How to evalute a string twice in Powershell

anyone know how to evalute a string twice in powershell? from example $l1 = yes $l2 = no for (i=0;i -lt 2; i++) { echo $1$i } ...

Matching a Repeating Sub Series using a Regular Expression with PowerShell

I have a text file that lists the names of a large number of Excel spreadsheets, and the names of the files that are linked to from the spreadsheets. In simplified form it looks like this: "Parent File1.xls" Link: ChildFileA.xls Link: ChildFileB.xls "ParentFile2.xls" "ParentFile3.xls" Blah Link: ChildFileC.xls Link: ChildFi...

Create multiple instances of custom Powershell object

I am creating a new object in a Powershell script, or actually an object type. I want to create multiple instances of this object. How do I do this? The code below is what I am working on, it appears that all instances in the array reference the same object, containing the same values. # Define output object $projectType = new-object ...

Creating aliases in PowerShell for git commands?

Hi, I understand how to create aliases in PowerShell for cmdlets fine but I want to create an alias in PowerShell for things like "git status" as just "gs" and "git pull origin master" as "gpm" can anyone point me in the right direction? I am sure I am missing something obvious. Many thanks Richard ...

Is it possible to extend indexers in PowerShell?

PowerShell's type extension facility is neat, but I haven't yet figured out the way -- if one exists -- to extend an indexer. I've tried to add a ScriptProperty for the indexer property (Chars in the case of System.String) and a ScriptMethod for the getter (get_Chars), but neither approach seems fruitful. Is it at all possible, or am I w...

Creating an IIS 6 Virtual Directory with PowerShell v2 over WMI/ADSI

I can create an IISWebVirtualDir or IISWebVirtualDirSetting with WMI, but I've found no way to turn the virtual directory into an IIS Application. The virtual directory wants an AppFriendlyName and a Path. That's easy because they're part of the ...Setting object. But in order to turn the virtual directory into an App, you need to set Ap...

Listing available COM Objects with Powershell

I am currently using the following script to list the available COM Objects on my machine. $path = "REGISTRY::HKEY_CLASSES_ROOT\CLSID\*\PROGID" foreach ($obj in dir $path) { write-host $obj.GetValue("") } I read on another website that the existence of the InProcServer32 key is evidence that the object is 64 bit compatible. So u...

Useful PowerShell Modules

What are the best or most useful dev-related PowerShell modules that exist today? Not looking for sys admin management tools for Active Directory/Microsoft Exchange/etc., but more for development utilities. Please list one module per answer, so they can be voted up accordingly. I'll provide a few to start off. ...

how to query list in powershell

add-type -Language CSharpVersion3 -TypeDefinition @" public class pack_code { public pack_code() {} public string code { get; set; } public string type { get; set; } } "@ $a = New-Object pack_code $a.code = "3" $a.type = "5" $b = New-Object pack_code $b.code = "2" $b.type = "5" $c = New-Object pack_c...

trying to connect to remote Exchange server 2007 from powershell

hi all, Am getting SSL error while connecting to remote exchange server. Can any one help me. Thanks & Regards Vijaybhasker ...