I have a pacfile which I am trying to update and need to remove content between two strings; the strings themselves should be kept:
// OFFICE 365 DIRECT ACCESS
and
// END OFFICE 365 DIRECT ACCESS
example:
// OFFICE 365 DIRECT ACCESS
if (isInNet(hostip, "23.103.132.0","255.255.252.0") || //EOP
isInNet(hostip, "23.103.136.0","255.255.248.0") || //EOP
isInNet(hostip, "23.103.144.0","255.255.240.0") || //EOP
isInNet(hostip, "23.103.191.0","255.255.255.0") || //EOP
// END OFFICE 365 DIRECT ACCESS
I want to remove the lines between the top and bottom lines
$Pacfile = Get-ChildItem .\o365.pac | Get-Content -Raw
$startstring= " \/\/ OFFICE 365 DIRECT ACCESS(.*? )\/\/END OFFICE 365 DIRECT ACCESS"
$NewPacfile = [regex]::match($Pacfile, $startstring).Groups[1].value
$NewPacfile