Hi All,
I'm using Posh-SSH to download a file through SFTP. When I try to format the date to get the correct file string to download it gives me an error. Can't figure out why, please help?
$LocalPath="d:\test1\"
$LocalTime=(Get-Date(Get-Date-FormatyyyyMMdd)).AddDays(-1)
$RemoteFile="POD_EXTRACT_"+$LocalTime.ToString()
Write-Host$RemoteFile
Get-Date : Cannot bind parameter 'Date'. Cannot convert value "20170821" to type "System.DateTime". Error: "String was not recognized as a valid DateTime."
At D:\Test1\VSoft_POD.ps1:6 char:25
+ $LocalTime = (Get-Date (Get-Date -Format yyyyMMdd)).AddDays(-1)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-Date], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.GetDateCommand
POD_EXTRACT_20170821
PS C:\Windows\System32\WindowsPowerShell\v1.0>