Kindly assist please, this code is report error, in light of the space around C. I thought it wihit space created by the .ToString.
Blockquote
function Set-ArchivePath{
[CmdletBinding()]
[OutputType([string])]
param (
[Parameter(Mandatory=$true)]
[string]$ZipPath,
[Parameter(Mandatory=$true)]
[string]$ZipPrefix,
[Parameter(Mandatory=$true)]
[datetime]$Date
)
if(-not(Test-Path -Path $ZipPath)){
New-Item -Path $ZipPath -ItemType Directory | Out-Null
Write-Verbose "Creating Directory '$ZipPath'"
}$TimeString = $Date.ToString('yyyyMMdd')
$ZipName = "$($ZipPrefix)$($TimeString).zip"
$fileName = (Join-Path $ZipPath $ZipName)
I have attached the code, the output is below
New-Item:
Line |
15 | New-Item -Path $ZipPath -ItemType Directory | Out-Null
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Cannot find drive. A drive with the name '"C' does not exist.
Join-Path:
Line |
19 | $fileName = (Join-Path $ZipPath $ZipName)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Cannot find drive. A drive with the name '"C' does not exist.
Test-Path:
Line |
21 | if(Test-Path -Path $fileName){
| ~~~~~~~~~~~~~~~~~~~~~~~~~