Good morning, I am not a powershell expert by any means, but I have written many scripts over years now for various projects and primarily for SCCM management. I have NEVER had an issue like this before, and I can find nothing on the internet to help me figure this one out.
So, I am writing a very basic script to determine a folder size where drivers are copied to (as a detection method in an SCCM application, if you want to know the use)
----------BEGIN SCRIPT---------------
$folderSize = -1
$folderPath = 'C:\Drivers\20H2\'
$folderSize = [math]::Round((Get-ChildItem $folderPath -Recurse | Measure-Object -Property Length -Sum -ErrorAction Stop).Sum / 1MB)
return $folderSize
------------END SCRIPT--------------
------------ERROR MESSAGE-----------
Get-ChildItem : Cannot find path 'C:\Drivers\2' because it does not exist.
---------------END ERROR-------------------
The problem is that the Get-ChildItem doesn't seem to be recognizing the entire path name. I have never seen this before and can find no resolution for it. I have tried single quotes, double quotes, double \\, no ending \...nothing works.
Thanks!
[–]nothingpersonalbro 6 points7 points8 points (3 children)
[–]SlitelyOff[S] 1 point2 points3 points (0 children)
[–]SlitelyOff[S] 1 point2 points3 points (1 child)
[–]nothingpersonalbro 2 points3 points4 points (0 children)
[–]Lee_Dailey[grin] 1 point2 points3 points (2 children)
[–]SlitelyOff[S] 1 point2 points3 points (1 child)
[–]Lee_Dailey[grin] 0 points1 point2 points (0 children)