Try the following.
$d = [datetime](Get-ItemProperty -Path $source -Name LastWriteTime).lastwritetime
This is part of the item property weirdness. When you run Get-ItemProperty it does not return the value but instead the property. You have to use one more level of indirection to get to the value.
Related Posts:
- Get file version in PowerShell
- How to use execvp()
- How to use execvp() to execute a command
- What is a reverse shell?
- Meaning of “! -S” in shell script
- “No such file or directory” but it exists
- How do I pause my shell script for a second before continuing?
- How do I split a string on a delimiter in Bash?
- PowerShell says “execution of scripts is disabled on this system.”
- PowerShell says “execution of scripts is disabled on this system.”
- How do I start PowerShell from Windows Explorer?
- How to execute a program or call a system command?
- In the shell, what does ” 2>&1 ” mean?
- How to run a PowerShell script
- How to run powershell script from .ps1 file?
- Extract substring in Bash
- Where to place $PATH variable assertions in zsh?
- Ubuntu says “bash: ./program Permission denied” [closed]
- Should I put #! (shebang) in Python scripts, and what form should it take?
- Should I put #! (shebang) in Python scripts, and what form should it take?
- Connect-AzAccount – how to avoid azure device authentication?
- How do I concatenate strings and variables in PowerShell?
- PowerShell equivalent to grep -f
- How do you comment out code in PowerShell?
- Running a command as Administrator using PowerShell?
- Setting Windows PowerShell environment variables
- In the shell, what does ” 2>&1 ” mean?
- How do I use a regex in a shell script?
- How do I copy a folder from remote to local using scp?
- How do I concatenate strings and variables in PowerShell?
- How to concatenate string variables in Bash
- How to use operator ‘-replace’ in PowerShell to replace strings of texts with special characters and replace successfully
- Replace substring in PowerShell
- -bash: syntax error near unexpected token `)’
- Echo equivalent in PowerShell for script testing
- How to use _CRT_SECURE_NO_WARNINGS
- How to grep for case insensitive string in a file?
- An example of how to use getopts in bash
- Difference between wait and sleep
- Echo equivalent in PowerShell for script testing
- PowerShell says “execution of scripts is disabled on this system.”
- Multi-line string with extra space (preserved indentation)
- How to use the curl command in PowerShell?
- Check if a file exists or not in Windows PowerShell?
- How to run a PowerShell script
- PowerShell and the -contains operator
- Change directory in PowerShell
- How to delete from a text file, all lines that contain a specific string?
- How to handle command-line arguments in PowerShell
- Multi-line string with extra space (preserved indentation)
- Splitting a string into separate variables
- How to split string by string in Powershell
- How to split string by string in Powershell
- ‘\r’: command not found – .bashrc / .bash_profile [duplicate]
- How to mkdir only if a directory does not already exist?
- How can I recursively find all files in current and subfolders based on wildcard matching?
- How to perform grep operation on all files in a directory?
- Loop through an array of strings in Bash?
- ‘\r’: command not found – .bashrc / .bash_profile [duplicate]
- How to export data to CSV in PowerShell?
- How can I check if a directory exists in a Bash shell script?
- Downloading a file with PowerShell
- How do I iterate over a range of numbers defined by variables in Bash?
- Terminating a script in PowerShell
- Why do people write #!/usr/bin/env python on the first line of a Python script?
- OS X: equivalent of Linux’s wget
- How to run an EXE file in PowerShell with parameters with spaces and quotes
- How to run an EXE file in PowerShell with parameters with spaces and quotes
- How to set ssh timeout?
- commands not found on zsh
- How do I pass multiple parameters into a function in PowerShell?
- subprocess.Popen(): OSError: [Errno 8] Exec format error in python?
- How to substitute shell variables in complex text files
- sudo: apt-get: command not found
- How do I iterate over a range of numbers defined by variables in Bash?
- Terminating a script in PowerShell
- Prompt for user input in PowerShell
- Why do people write #!/usr/bin/env python on the first line of a Python script?
- How to mkdir only if a directory does not already exist?
- OS X: equivalent of Linux’s wget
- Using find to locate files that match one of multiple patterns
- How can I recursively find all files in current and subfolders based on wildcard matching?
- How to upgrade PowerShell version from 2.0 to 3.0
- How do I concatenate strings and variables in PowerShell?
- Curl command for https ( SSL )
- “unary operator expected” error in Bash if condition
- How to exclude a directory in find . command
- Python error message io.UnsupportedOperation: not readable
- What does “-ne” mean in bash?
- “sed” command in bash
- How can I declare and use Boolean variables in a shell script?
- Python -How to solve OSError: [Errno 22] Invalid argument
- How to reload .bashrc settings without logging out and back in again?
- Is there a Python equivalent to the ‘which’ command
- Array.Add vs +=
- PowerShell and the -contains operator
- How to exclude a directory in find . command
- How can I declare and use Boolean variables in a shell script?
- How to reload .bash_profile from the command line?
- What is the purpose of “&&” in a shell command?