basically my code is designed to create a list of specific servers. it takes 4 inputs, 3 of which make up the naming convention of our servers and the 4th to determine how to output the returned info.
the first is a text box where you enter the customer code.
the second is the farm type: prod, DR, or PPE
the third is the role: sql, backup, front end or app server
and the fourth is how i want the information output, whether onscreen to the rich text box or output to a file.
the script that does that is:
Code: Select all
$CCode = $null
$Role = $null
$Farm = $null
$Ccode = read-host "What customer? (Please use 3 digit Customer code)"
$Role = read-host "What server role? (FE, AP, SQ)"
$Farm = read-host "which farm? (Prod=P, DR=S, PPE=T)"
If ( $Farm -ne $p -or $s -or $t )
{
$Farm = read-host "which farm? (Prod=p, DR=s, PPE=t)"
}
switch( read-host "[1] Display
[2] Export to servers.txt
Choose Option" )
{
1 {
Import-Module "CMDB" -Force
Get-SPODCustomerServer | where {$_.CustomerCode -eq "$Ccode" -and $_.ServerRole -eq "$Role" -and $_.EnvironmentType -eq "$Farm"} | select servername | sort-object servername | out-gridview
}
2 {
Import-Module "CMDB" -Force
Get-SPODCustomerServer | where {$_.CustomerCode -eq "$Ccode" -and $_.ServerRole -eq "$Role" -and $_.EnvironmentType -eq "$Farm"} | Sort-object servername | %{"$($_.ServerName)"} | out-file servers.txt
write-host "Server names have been exported to servers.txt" -ForegroundColor Yellow
}
}
im trying to modify it to work in the form but i really dont understand how to set up the radio buttons and such.