powershell

Use PowerShell to Compare SharePoint User Meta Data in User Profile and User Information List

Hi, I came across a request on LinkedIn for a PowerShell script that was required to: Retrieve all users from the given SharePoint site-collection For each user, the script must retrieve the properties are common between "User Profile" and "User Information List" If any of the common fields between the two are different, the user name...

powershell remote installing apps

I am trying to install a msi from a network share remotely. $app = [WMICLASS]"\\$pcname\ROOT\CIMV2:Win32_Product" $app.Install($AppPath) I am getting an err 1619. From some sources say that WMI cannot install remotely with first coping it to the local computer and running it. Some sources use this command to exactly. That way works g...

Get parent property in child select in Powershell?

I want to include a parent level property in a child result set in Powershell and I can't figure out how to do it. An example of what I want to do would be to include the ServerName as the first column of a pipe to get the DatabaseName and a list of Database properties of all the databases on the server similar to: [System.Reflection.A...

How to execute an external console apllication with PoweShell and send the result to email?

Hey, sorry for my bad english... i need to execute some periodic console applications that give me some results (on the console)... How can I execute it and have its return data sent to my email? I tried to use [Diagnostics.Process]::Start() and it launches my application but i don't know how to get the return... I do not want the exitCo...

Can RunWithElevatedPrivileges be used in a PowerShell script?

If yes, please give an example. UPDATE: I have a PowerShell script that iterates through all site collections within selected Web application and changes the siteCollection.Audit.AuditFlags property. It works fine on my development machine, but the siteCollection.Audit.Update() command fails with Access is denied error on the productio...

Getting values from get-eventlog Powershell call

Sorry to ask such a question, but I've spent 1/2 hour on this and no good solution. I want to get the latest date from the Event Log for a particular app. So far, my code is: $event = get-eventlog -logname 'Windows PowerShell' -source mpkLogParser -newest 1 | Format-List echo $event this yields: Index : 51 EntryType ...

How to Handle Command Line Arguments in PowerShell

I am sooo stuck on something this morning. The "best" way to handle command line arguments. It seems like there are several answers on what the "best" way is and as a result I am stuck on how to handle something as simple as: script.ps1 /n name /d domain AND script.ps1 /d domain /n name. Is there a plugin that can handle this better? I ...

powershell bash loops are randomly stuck waiting for keyboard input

Hi all, I am facing a curious issue. I have bash script I am running from powershell in windows that does a for loop. Every once in a while, one of the loop iteration hangs until I hit enter on the keyboard. This doesn't happen all the time, in fact, it happens pretty rarely. But it still does. The interesting thing is that my loop...

Calling Echo inside a function pre-pends echo string to return value in Powershell

Hey guys, I'm a Powershell noob and seem to keep getting caught on little weird behaviors like this. Here is some test code: function EchoReturnTest(){ echo "afdsfadsf" return "blah" } $variable = EchoReturnTest echo ("var: " + $variable) Running this script generates this as output: "var: afdsfadsf blah" Why does the...

In Powershell, what's the most efficient way to split a large text file by record type?

I am using Powershell for some ETL work, reading compressed text files in and splitting them out depending on the first three characters of each line. If I were just filtering the input file, I could pipe the filtered stream to Out-File and be done with it. But I need to redirect the output to more than one destination, and as far as I...

Join string with non-breaking space in Powershell

I try to $arr = "one", "two" $test = [String]::Join(@"\u00A0", $arr) and it gives me Unrecognized token in source text. Is it because i have to specify it in utf-8 as 0xC2 0xA0? ...

powershell xml xpath

In Powershell, suppose I have the following xml: <Users> <User Name="Foo"> <Friends> <Friend Name="Bar"/> </Friends> </User> <User Name="Foo2" /> <User Name="Foo3"> <Friends> <Friend Name="Bar"/> </Friends> </User> </Users> How can I get all the users that have a "Bar" as...

Is it possible to use Powershell to make changes to Application Request Routing (ARR) in IIS7?

I'm working on some scripts to automate deployments. I use IIS7 ARR to load balance between two servers. When doing a deployment I take one of the two out of load balancing and my powershell script deploys code to that server so I can test it before making it live. It would be awesome if the script could also do the work of taking t...

IIS 6 ServerBindings with WMI and Powershell v2

I've long had a bunch of VBS automations for IIS 6, including one that gets/sets complex server bindings on several farms of paired servers, each having dozens of apps, each app having 3-12 host headers. Each app has hostname, hostname-fullyqualified, and Disaster Recovery enabled hostname, so they can be a mess to maintain manually. I...

Where do I download Windows PowerShell v2 (2.0) RTM?

Is there a direct link to download Windows PowerShell v2 (2.0) RTM? Google's first page of search results isn't helping, and I don't want to download the entire Windows Management Framework. ...

A tool/script to check the difference betwen two "web.config" files

can you please share with me if you have any tool/script to check the difference between two "web.config" files. ...

CreateProcess, process do not terminate when redirecting std out/in/err

Hi, I'm trying to use CreateProcess to launch a powershell script from within my application. I've used the Microsoft example (http://msdn.microsoft.com/en-us/library/ms682499(VS.85).aspx) to create the child process and redirect the standard out/in/err pipes. The only issue left to solve is why the child process (powershell) do not ...

Properly displaying a tray balloon tooltip in PowerShell

Short version: I think I need help with properly using events in PowerShell that are invoked as a result of a Windows Message to get rid of a balloon tooltip's icon. Long Version: I have a long-running PowerShell command (a build) that I would like to be notified when it completes via a balloon tooltip in the system tray/notification a...

Powershell match a single string against multiple regexs?

Is there a more 'powershelly' way of matching a single string against an array/collection of regexes other than iterating through each one in turn? What I'd really like to be able to do is something this $database.Name -match $includeRegexArray Given the way Powershell works it feels like there should be a nicer solution than writing ...

Powershell -- working with a null DataTable

Given this code: $connection = new-object system.data.sqlclient.sqlconnection( ` "Data Source=$server;Initial Catalog=$instance;Integrated Security=SSPI;"); $adapter = new-object system.data.sqlclient.sqldataadapter ($query, $connection) $set = new-object system.data.dataset $adapter.Fill($set) | out-null $table = new-object syst...