Get-SFTPChildItem: Can't assign LastWriteTime of file to a [DateTime] variable
This works as expected: Get-SFTPChildItem -SessionID $SFTP_Session.SessionID -Path /home/wd/UPDATES/ -Recurse -File | select LastWriteTime -expandproperty LastWriteTime
This doesn't work, variable = $null: [DateTime] $FileLastWrite = Get-SFTPChildItem -SessionID $SFTP_Session.SessionID -Path /home/wd/UPDATES/ -Recurse -File | select LastWriteTime -expandproperty LastWriteTime
Many thanks for creating this module!
The command is processing multiple files, each returning s value, so a collection is being returned but you are casting a single value, I would move the casting for datetime at the end of the pipes Sent from my iPhoneOn Jan 17, 2024, at 4:04 PM, MickeyDamn @.***> wrote: This works as expected: Get-SFTPChildItem -SessionID $SFTP_Session.SessionID -Path /home/wd/UPDATES/ -Recurse -File | select LastWriteTime -expandproperty LastWriteTime This doesn't work, variable = $null: [DateTime] $FileLastWrite = Get-SFTPChildItem -SessionID $SFTP_Session.SessionID -Path /home/workday/AD_UPDATES/ -Recurse -File | select LastWriteTime -expandproperty LastWriteTime Many thanks for creating this module!
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.***>
Thank you for the reply and advice!