header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
UPdate a Config File
Last Post 02 Sep 2009 06:51 PM by seaJhawk. 1 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
edm365f31User is Offline
Basic Member
Basic Member
Posts:100
Avatar

--
02 Sep 2009 12:15 PM
    I am running a script that will update a config file

    $FC = GC C:\File\Trivoli.config

    In this config file i am grepping for this line

    property-set name="HonorProcessScheduledEndTime" value="true"
     

    If the value in this line is "true" I need to change the value to "false"
    I then need to restart the trvoli service so the update on this config file takes effect.
    If the Value is already "false" then I just need to write-host the file is already updated.

    Here's the Rough Script, thanks for looking.

    $FC = GC C:\File\Trivoli.config
    $FC | foreach { If ( $_ -like "*Runthisprogram*")
    {$_ -replace "true", "false"
    Stop-Service w32time -verbose
    Start-Sleep -sec 2
    Start-service w32time -verbose
    } Else
    { Write-Host  Config already updated}
    }
    seaJhawkUser is Offline
    Basic Member
    Basic Member
    Posts:191
    Avatar

    --
    02 Sep 2009 06:51 PM
    Are you having a problem with the script?

    The only thing I see without testing that would cause a problem is that while you are not writing the updated string back to the file.

    You can collect your results (e.g. $results += $_) and then save them to the file ($results | out-file c:\file\trivoli.config -force) before you restart the service.

    -Chris
    You are not authorized to post a reply.


    Active Forums 4.3
    right
    footer   footer
    footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
    footer   footer