My script outputs a text file of any websites being hosted. The text file would look like the following:
Default Settings Layouts Stackexchangelogon
I need to get these into a CSV file with the following headers:
- Type
- Base
- Status
For Type, I need website name, Base, I need it to have IIS and for Status, I need to have Monitored.
The final output would be something like,
Type Base Status Default IIS Monitored Settings IIS Monitored Layouts IIS Monitored Stackexchangelogon IIS Monitored
I have searched the web and still puzzled on how to achieve this. It needs to work on PowerShell 2.0 because of Windows 2003 hosts.
This is what I have so far -
$website = Get-content "D:\Websites.txt"
$CSV = @()
$row = New-Object System.Object
$website | ForEach-Object {
$row | Add-Member -MemberType NoteProperty -Force -Name "Type" -Value $_
$row | Add-Member -MemberType NoteProperty -Force -Name "Base" -Value "IIS"
$row | Add-Member -MemberType NoteProperty -Force -Name "Status" -Value "Monitored"
$CSV += $row
}
But its not adding each website. I get repeats of the last one on the list. Result:
Type Base Status ---- ---- ------ Stackexchangelogon IIS Monitored Stackexchangelogon IIS Monitored Stackexchangelogon IIS Monitored Stackexchangelogon IIS Monitored
Any ideas?