I have a little problem when running this powershell script form a central location. If i run from a central location i keep getting:-
Get-Content : Cannot bind argument to parameter 'Path' because it is null.
and
Set-Content : Cannot bind argument to parameter 'Path' because it is null.
If i run this within the $Dest lcation it works without errors, how can i get this script to run to change files?
$path = "K:\Business Systems\Microsoft Development\Deploy"
$Date = (get-date -uformat '%d%m%Y')
$DateTime = (get-date -uformat '%d/%m/%Y %H:%M:%S')
$Dest = "c:\testing\"
$LogCopy = "C:\testing\code_drop_FileCopy$Date.log"
$LogRename = "C:\testing\code_drop_RenameFiles$Date.log"
$LogRenameEtl = "C:\testing\code_drop_RenameEtl$Date.log"
write-output "$DateTime Logging started" | out-file -append $logrename
$configFiles=get-childitem $Dest *.config -recurse -verbose -force | out-file -width "500" -append $logrename
foreach ($file in $configFiles)
{
(Get-Content $file.PSpath) | out-file -append $logrename
Foreach-Object {$_ -replace "%%DATABASE_SERVER%%", "SERVER"} |
Foreach-Object {$_ -replace "%%DATABASE_CATALOG%%", "DB"} |
Foreach-Object {$_ -replace "%%DATABASE_USER%%", "USER"} |
Foreach-Object {$_ -replace "%%DATABASE_PASSWORD%%", "PASSWORD"} |
Set-Content $file.PSpath -verbose | out-file -append $logrename
Write-host "$DateTime Files Amended" | out-file -append $logrename
write-output "$DateTime Logging Finished" | out-file -append $logrename
Any help would be appreciated.
Get-Content : Cannot bind argument to parameter 'Path' because it is null.
and
Set-Content : Cannot bind argument to parameter 'Path' because it is null.
If i run this within the $Dest lcation it works without errors, how can i get this script to run to change files?
$path = "K:\Business Systems\Microsoft Development\Deploy"
$Date = (get-date -uformat '%d%m%Y')
$DateTime = (get-date -uformat '%d/%m/%Y %H:%M:%S')
$Dest = "c:\testing\"
$LogCopy = "C:\testing\code_drop_FileCopy$Date.log"
$LogRename = "C:\testing\code_drop_RenameFiles$Date.log"
$LogRenameEtl = "C:\testing\code_drop_RenameEtl$Date.log"
write-output "$DateTime Logging started" | out-file -append $logrename
$configFiles=get-childitem $Dest *.config -recurse -verbose -force | out-file -width "500" -append $logrename
foreach ($file in $configFiles)
{
(Get-Content $file.PSpath) | out-file -append $logrename
Foreach-Object {$_ -replace "%%DATABASE_SERVER%%", "SERVER"} |
Foreach-Object {$_ -replace "%%DATABASE_CATALOG%%", "DB"} |
Foreach-Object {$_ -replace "%%DATABASE_USER%%", "USER"} |
Foreach-Object {$_ -replace "%%DATABASE_PASSWORD%%", "PASSWORD"} |
Set-Content $file.PSpath -verbose | out-file -append $logrename
Write-host "$DateTime Files Amended" | out-file -append $logrename
write-output "$DateTime Logging Finished" | out-file -append $logrename
Any help would be appreciated.