Question : How to replace strings in a text file using powershell

I have the following scripts:

$homepage = "http://www.site.com"
$old = "^user_pref`(`"browser.startup.homepage`"`,"
$new = "user_pref`(`"browser.startup.homepage`"`, `"$homepage`"`);"
(Get-Content prefs.js) | Foreach-Object {$_ -replace $old, $new} | Set-Content prefs2.js

but the error returned by powershell is as follows:

Invalid regular expression pattern: ^user_pref("browser.startup.homepage",.
At line:1 char:59
+ (Get-Content prefs.js) | Foreach-Object {$_ -replace $old,  <<<< $new} | Set-
Content prefs2.js

Answer : How to replace strings in a text file using powershell

Print Spooler The Print Spooler system service manages all local and network print queues and controls all print jobs. Print Spooler is the center of the Windows printing subsystem. It manages the print queues on the system and communicates with printer drivers and input/output (I/O) components, such as the USB port and the TCP/IP protocol suite.

System service name: Spooler

Application protocol     :     Protocol : Ports

NetBIOS Datagram Service UDP 138

NetBIOS Name Resolution UDP 137

NetBIOS Session Service TCP 139

SMB TCP 445

Note The Spooler service uses RPC over named pipes. This service has the same firewall requirements as those of the "File and Printer Sharing" feature.

See this MS doc for full Service and Network port requirement for the Windows Server system....  http://support.microsoft.com/kb/832017

Random Solutions  
 
programming4us programming4us