Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a problem in a script where i need to select a string and put it into a file.
I need to use the "Get-Website" cmmdlet in powershell to pull the ID

right now i am using Get-Website *sitename |fl ID now the output comes along like "id : 15"
i need to drop this down to sjust the ID number and use it elsewhere in the script to then inject it into a .txt file so that a perl script can come along and use it for stats

share|improve this question

Try this:

$val = ($string -split ": ")[1]
share|improve this answer
that does not seem to work, even when running the output of Get-Website via a | to it it errors on the $string – BeStRaFe Aug 27 '10 at 0:11
@BeStRaFe: $string = Get-Website *sitename |fl ID then the line above. Or $val = ((Get-Website *sitename |fl ID) -split ": ")[1] – Dennis Williamson Aug 27 '10 at 0:39
Get-Website *sitename | Foreach-Object {$_.Id}
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.