powershell

How do I interact with an Iframe using Powershell?

I'm trying to automate a website and find myself needing to get to the contents of an iframe. Since this is an internal application, I've put in this sample, which illustrates the error $ie = new-object -com "InternetExplorer.Application" $ie.navigate("http://arstechnica.com/") $ie.visible = $true $doc = $ie.document $maglistcontro...

Open url from script on Windows Server 2008

I want to write a script that loads a url (eg. http://google.com) automatically. But I don't want to install any 3rd party libraries or programs to the server. what's the easiest way to do this? I just my options are batch script, vb script or powershell right? ...

powershell : xcopy directory template acl to a new folder

I'm trying to do an xcopy /o equivalent to copy a template folder with subdirectories which contain their own appropriate acl to create a new target directory with the same subdirectories and their respective acl in a windows 2008 server environment. for example.. the template directory would be templatedir - sql - pm - dev tar...

PowerShell: Subdirectory listing to a txt-file

Hello! Today I started scripting in Windows PowerShell - so please excuse my "dumbness"... I want to create txt-Files with the name of the subfolders of each "rootfolder" on drive G:. On G:\ I have the following folders: 1_data 2_IT_area 3_personal 4_apprenticeship 7_backup 8_archives 9_user_profile So I wrote this script: get-chil...

Create DFS folder with particular permisson ?

How to create DFS Folder with particular permisison using powershell script ...

Pass a Parameter object (PSCredential) inside a ScriptBlock programmatically in C#

I am trying to run an HPC cmdlet programmatically to change HPC install credential on a remote computer. If run the cmdlet locally, it's pretty straightforward: Runspace rs = GetPowerShellRunspace(); rs.Open(); Pipeline pipeline = rs.CreatePipeline(); PSCredential credential = new PSCrede...

Run powershell script automatically after MSDeploy

As a part of the deployment process, I'd like the user to specify a password that is encrypted after the deployment process. For encrypting the password, I need to call the aspnet_regiis or use C#. How do I automatically invoke a script/or command line command after the deployment is complete (deployment is done either using GUI on IIS (...

Set-ItemProperty won't include newlines (powershell)

I'm trying to use set-itemproperty to add an item to: HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup\Installation Sources $InstallationSources = Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup" -Name "Installation Sources" $test = $InstallationSources."Installation Sources" + "C:\Test\I386" Set-ItemPropert...

How you do a ‘Pause’ with PowerShell 2.0?

Ok I'm losing it. Powershell is annoying me. I'd like a pause dialog to appear and it won't. PS W:\>>> $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") Exception calling "ReadKey" with "1" argument(s): "The method or operation is not implemented." At line:1 char:23 + $host.UI.RawUI.ReadKey <<<< ("NoEcho") + CategoryInfo : No...

Using Powershell how do I delete a line from a text file by it's line number?

In Powershell - Say I want to delete line 5 from a 10 line text file using the line number, how is this done? Thanks, Daniel ...

"Group by day" in PowerShell

Ok I have this script where I read in a CSV (converted from a XLS) and save an ID-field as well as a date-field into an array. Like so: New-Object PSObject -prop @{ TheId = $_."The ID"; TheDate = [DateTime]::Parse($_."The Date") } It works like a charm and I get a nice array of objects with the two properties above. Now, I wou...

PowerShell, Object = Start Process?

Hi I would like to start the Internet Explorer without extensions and control it. (Navigate to other pages, click buttons etc.) When I use the command: "Start iexplore.exe -ArgumentList -extoff" I have the IExplore without extensions, but no object. I need the object to navigate to different pages and click buttons. "$ie = Start iexplor...

Copy-Item problem with destination

I have two Copy-Item commands Copy-Item "C:\Test\folder1" "\\remote_machine\destination" -Recurse Copy-Item "C:\Test\folder2" "\\remote_machine\destination" -Recurse folder1 and folder2 contain folders and files Both commands are similar, but I get different results Copy content of folder1 to destination - OK Copy folder2 with al...

Powershell 2 event handling

Hi Powershell experts! I'm trying to script Powerpoint with Powershell 2.0. This site says there's a "PresentationOpen" event. However, Get-Member does not show this event. Also, when I try to do this: register-objectevent $application PresentationOpen notification_event it says: "Cannot register for event. An event with name 'Prese...

Powershell Backgroundworker

Can anyone give me an example of how to use BackgroundWorker in Powershell? I want to write something so when a new tab is selected in my Powershell GUI app, it will switch to the tab with a "please wait" message displayed, then run some checks in a BackgroundWorker thread, and then update. Is this possible in Powershell? All the Googl...

Sorting xml document in powershell

I'd like to sort the following xml document using powershell. <car> <germany> <manufacturer>Opel</manufacturer> <manufacturer>BMW</manufacturer> <manufacturer>Benz</manufacturer> </germany> <japan> <manufacturer>Nissan</manufacturer> <manufacturer>Daihatsu</manufacturer> </japan></car> So the elements inside german...

Powershell pack uri object

I'm trying to create a pack ui referencing a xaml resource inside of an assembly file in powershell. After reading this post I tried to do this: $resource = new-object system.uri("pack://application:,,,/WPFResource;component/test.xaml") The I get an error noting that it is expecting a port since there are two colons. Can anyone pleas...

Powershell: modifying text

ok, I give up! why doesn't this work? Im just trying to loop through a csv file and replace any value in the nth column with some value. $source = "C:\blah.csv" (gc $source) | foreach{ $_.Split(',')[10] = 'something'} | sc $source ...

Logging from powershell-script to csharp-program (log4net - logfile)

Hello, I have written a program with C#, that creates a logfile and fills this by using log4net. This program starts powershell-scripts. The scripts should use log4net, too. I want to monitor what the scripts log to log4net while they are running and write this information in my logfile. Have you an idea how I do this or where I get in...

Calling function from Powershell Cmdlet

I'm trying to create a cmdlet that calls Powershell function. Can this be done? Idea is to have static cmdlet that enumerates a set of data and then calls defined function to do something for each item. I can always copy - paste a base template for the enumaration part, but it really easy to make errors while making modification to para...