powershell

BadEnumeration while iterating over sharepoint list fields

I'm trying to insert a bunch of data into a SharePoint list. The List is a custom list based on the Item content type with a couple of custom columns, Contact and Code, where code is a custom field type based on SPFieldText. I am exploring the list using PowerShell 2.0, and enumerating the fields of the list (or any given list item) ca...

How to get PowerShell to wait for Invoke-Item completion?

How do I get PowerShell to wait until the Invoke-Item call has finished? I'm invoking a non-executable item, so I need to use Invoke-Item to open it. ...

Folder cleanup with PowerShell

I'd like to clean up some directories after my script runs by deleting certain folders and files from the current directory if they exist. Originally, I structured the script like this: if (Test-Path Folder1) { Remove-Item -r Folder1 } if (Test-Path Folder2) { Remove-Item -r Folder2 } if (Test-Path File1) { Remove-Item File1 } N...

How can I stop and start individual websites in IIS using PowerShell?

I have multiple sites configured in IIS7 on my Windows7 development machine to run on the same port and usually only run one at a time depending on what I'm working on. I would like to be able to start and stop my development sites from PowerShell instead of having the IIS manager opened. Does anyone have a good resource to point me in...

Trouble with Powershell and running a complex commandline

Hi, I've been trying to run the following command line from a Powershell build script we have; but keep running into issues & 'C:\Dev\Yadda\trunk\BuildScripts\U tilities\csmanage.exe' ` /create-deployment ` /name:yadddayaddyaddadev ` /label:yadddayaddyaddadev ` /package:https://yadddayaddyadda.blob.core.windows.net/mydeployment...

PowerShell Advanced Function get current ParameterSetName

In C# you can get the current ParameterSetName in the ProcessRecord override of a PowerShell Cmdlet with code like this: switch (ParameterSetName) { case FromUriParamSetName: loadFromUri(); break; case FromFileParamSetName: loadFromFile(); break; } I'm trying to figure out ho...

Different Uses of PowerShell With SharePoint?

Hi, Following the release of SharePoint 2010, there has been renewed interest in using PowerShell to manage SharePoint solutions. I'm interested in finding out how my peers are currently using PowerShell with SharePoint, either 2007 or 2010. For example, I use a PowerShell script to determine the number of sites, sub-sites and page...

How to get variables in the order they are declared

Is it possible to make Get-Variable always return variables in the order they've been declared? & { $c = 2 $b = 1 $a = 0 get-variable -scope local } ...

Is there a gentle way of stopping processes using Windows PowerShell?

I have to stop a browser from a PowerShell script, which I do by piping it into Stop-Process -Force However, this is very abrupt. When the browser is restarted, it detects that it didn't shut down cleanly, and tries to restart the previous session. Is there some way I can tell it to shut itself down gracefully? ("There are two ways we...

Powershell replace lose line breaks

Hi, I am a newbie in powershell. I have a simple powershell script that just replace text but I found that the regex replace turn my multiline data source into a single line text when the output is produced. I want the line breaks to be preserved. Here is the dumb down version of the script. $source=(Get-Content textfile.txt) $process1...

Powershell script required..

this is the scenario. p1 |_f1 |_f2 p2 |_f1 |_f2 Can anyone please help me with a powershell script that copies the files shown above from the TFS to a temporary folder ??? where f1,f2,and so on are the subfolders.. ...

Does -eq keyword in power shell test reference equality or use Object.Equals()

Does "-eq" in Powershell test reference equality (like "==" in c#) or does it do the equivalent of calling Object.Equals() ...

Powershell: align right for a column value from Select-Object in Format-Table format

I have the following array value $outData with several columns. I am not sure how I align some columns right? $outData | Select-Object ` Name ` @{Name="Freespace(byte)"; Expression={"{0:N0}" -f $_.FreeSpace}}, ' .... # other colums ` | Format-Table -AutoSize It works fine. However, when I tried to use align for the ...

Simple Win GUI - should I try PowerShell or just stick with HTA?

knowing what PowerShell can do on a command line I have never learned how to write GUIs with it. Should I? Or just go back to the good old HTA / VBScript? ...

How to inherite IIS 6 web site properties from configuration file .xml

Hi, I am trying to create web sites from IIS manager. I already have few web site and Application pools. I want to add few more and this is gonna happen again in future. So what i need right now is i want to inherit the properties of previously created web site and apppool to this new website. I mean how can i inherit the properties fr...

Is this an edge case in PowerShell's type resolution mechanism?

Here's my situation. I have a PowerShell module which imports the PowerShell-JSON library; this library converts JSON strings into PowerShell objects. My module provides an interface to CouchDB, so my JSON strings are obtained from HTTP calls. I have a function, Send-CouchDbRequest, which makes the HTTP request to CouchDB and returns ...

I want to copy all the files available in my TFS source server to a folder in a directory.I tried the below code but error is coming while achieving the same.Can you suggest some solution.

PS> C:\Windows\System32> Get-TfsItemProperty $/MyFirstTFSProj -r ` -server xyzc011b| Where {$_.CheckinDate -gt (Get-Date).AddDays(-150)} | Copy-Item D:\john\application1 -Destination C:\Test -whatif Copy-Item : The input object cannot be bound to any parameters for the command either because the command does not take pipeline i...

powershell errors on remove-item command

Hi, I've written a powershell script which removes folders more than 7 days old. It seems to be removing the folders, but for some reason its giving me errors. I was wondering if anyone might be able to tell me why? The script is... $rootBackupFolder = "\server\share" get-childitem $rootBackupFolder | where {$.PSIsContainer -AND $.Na...

how to copy files from TFS to clear case??

Can i use powershell script to copy a set of files from a folder to Clear Case..?? i have the task of synchronising files from TFS to Clear Case.. like i need to take a set of files aftr a certain date from tfs server and synchronise these files to Clear case.. ...

Mysterious different conversion to string[] of seemingly same input data

During investigation of some problem I found that the reason was unexpected different conversion to string[] of seemingly same input data. Namely, in the code below two commands both return the same two items File1.txt and File2.txt. But conversion to string[] gives different results, see the comments. Any ideas why is it? This might be...