Sorry noob to powersehell so forgive me if im asking a stupid question.
I am trying to dynamically create a hostfile for new users based on locally worked on websites. I am running a Get-IISSites against our staging WWW server and entering those into an array. as an example i am running a test vm with iis installed
$Array = @()
$Websites = Get-IISSite | Select-Object name, ID
foreach($WB in $Websites)
{
If($WB.ID -gt 1)
{
$Array += New-Object psobject -property @{'name' = $WB.name}
}
}
this is the output
Test1.mav359.co.uk
test2.mav359.co.uk
test3.mav359.co.uk
test4.mav360.co.uk
as you can see there are two domains, i need to achive 2 things
first i need to rename each site to test1-local.mav359.co.uk and i want to add IP1 or IP2 based on the domain to the end of the line, these will be replaced later based IPs generated and assigned to varibles generated against the local PC
Test1-local.mav359.co.uk IP1
test2-local.mav359.co.uk IP1
test3-local.mav359.co.uk IP1
test4-local.mav360.co.uk IP2
Im struggling to know how to manipluate the data i have in the array (or whether thats even the best way to go). I was thinking along the lines off doing a
foreach containing add ip1 or containg add ip2
i dont know how to/can you use a wild card to search/replace *.mav359.co.uk with *.-local.mav359.co.uk whilst retaining the original part of the line
Again knew to all this so id apppricate some help or pointing in the direction, are arrays the wrong way to go?
Cheers for any help
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…