This is a very small line of code to count Sharepoint 2010 Site Collections with Powershell.
(Get-SPSite -Limit all).Count
By the way, we at Genotec AG are offering a Hosted Sharepoint 2010 solution based on Powershell automation.
|
This is a very small line of code to count Sharepoint 2010 Site Collections with Powershell.
(Get-SPSite -Limit all).Count
By the way, we at Genotec AG are offering a Hosted Sharepoint 2010 solution based on Powershell automation.
Apple just released iOS 4.1 beta 2. After some testing I found something I was looking for in every release. In iOS 4.1 beta 2 you can now send calendar invites to other people by creating a new event.
After my first post (Powershell: Parsing XML part 1) about working with XML and Powershell, I have create this second post which describes how to create a XML file, Add content to the XML file, remove content from the XML file and save the XML objects as a file.
While I was writing a script which communicates with a webserver, I realized that I need some error handling if the server can not anwser a request from my script. For example if the webserver is down or has to much load.
I created a little retry part (Powershell: Simple retry logic) which retries several times. But if the Server is down for several hours or days your script hangs in a retry loop. Obviously this cant be the solution. After a little bit of thinking a decided to write the data, which I was trying to send, down in a XML file. And the next time the script runs it reads the XML file and tries to send the data again.
Thats the story behind my idea for saving data in a XML file.
[XML]$FruitList = "<Box> <Fruit> <Name>Banana</Name> <Color>yellow</Color> </Fruit> </Box>"
$FruitList.Save("./myfruitlist.xml")
XML:
<Box> <Fruit> <Name>Banana</Name> <Color>yellow</Color> </Fruit> </Box>
[xml]$FruitList = Get-Content ./myfruitlist.xml
# Copy Object from Banana
[Object]$CopyFruit = FruitList.Box.Fruit | Where-Object {$_.Name -eq "Banana"}
$NewFruit = $CopyFruit.Clone()
# Add Fruit to new Object
$NewFruit.Name = "Apple"
$NewFruit.Color = "green"
# Add Fruit to XML Object
$FruitList.Box.AppendChild($NewFruit)
#Save to XML object ot XML file
$FruitList.Save("./myfruitlist.xml")
XML:
<Box> <Fruit> <Name>Banana</Name> <Color>yellow</Color> </Fruit> <Fruit> <Name>Apple</Name> <Color>green</Color> </Fruit> </Box>
# Change Apple Color
$FruitList.Box.Fruit | Where-Object {$_.Name -eq "Apple"} | ForEach-Object { $_.Color = "red" }
#Save to XML object ot XML file
$FruitList.Save("./myfruitlist.xml")
XML:
<Box> <Fruit> <Name>Banana</Name> <Color>yellow</Color> </Fruit> <Fruit> <Name>Apple</Name> <Color>red</Color> </Fruit> </Box>
# Remove Banana from Object
$RemoveFruit = $FruitList.Box.Fruit | Where-Object {$_.Name -eq "Banana"}
$FruitList.Box.RemoveChild($RemoveFruit)
#Save to XML object ot XML file
$FruitList.Save("./myfruitlist.xml")
XML:
<Box> <Fruit> <Name>Apple</Name> <Color>green</Color> </Fruit> </Box>
After Coding some lines in a lot of different files you wanna know how much lines you have coded. There are two (I am sure there are even more) ways to do that. The first one is to get the content of the files (Get-Content) and count the lines in there.
The other way and the fasterway is with Select-String:
(Get-ChildItem -Include *.ps1 -Recurse | Select-String -pattern .).Count
With the new G7 Serverline, HP released also iLO 3 (HP Integrated Lights-Out). With new and important features:
Great!
I am working at some larger powershell scripts right now and so I needed to create a simple retry logic for sending web request to a server.