I am trying to a backup functionality before the deployment by creating folder with current dateTime, but I am facing error
Error:
= : The term ‘=’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or
if a path was included, verify that the path is correct and try again.
At line:1 char:6
- & { = Get-Date -Format ‘yyyy_MM_dd_HH_mm_ss’; = ‘D:CommonWebsites …
My pipeline code:
- npm install --force
- ng build --configuration prod
- powershell -Command "& {Import-Module WebAdministration; Stop-WebSite -Name 'mysite.com'}"
- powershell -Command "& {iisreset /stop}"
- powershell -Command "& {
$dateString = Get-Date -Format 'yyyy_MM_dd_HH_mm_ss';
$destinationPath = 'D:CommonWebsitescicdbackupsmysite-' + $dateString;
Copy-Item -Path 'E:WebsitesCommonmysite' -Destination $destinationPath -Recurse -Force;
Start-Sleep -Seconds 20;
}"
- powershell -Command "Remove-Item -Path 'E:WebsitesCommonmysite' -Recurse -Force;"
Everything works fine apart from backup step
Error occurs exactly at this line
- powershell -Command "& {
$dateString = Get-Date -Format 'yyyy_MM_dd_HH_mm_ss';
$destinationPath = 'D:CommonWebsitescicdbackupsmysite-' + $dateString;
Copy-Item -Path 'E:WebsitesCommonmysite' -Destination $destinationPath -Recurse -Force;
Start-Sleep -Seconds 20;
}"