I have a powershell script for foldercleanup. I want key value ($key) to be returned by a function called passval ,which is a separate file. but its not passing. This is the function
function passval{$s="cleanupfolder"
$s
return $s}
This is the main code
$colItems = (Get-ChildItem D:\00Newfolder -recurse | Measure-Object -property length -sum)
"{0:N2}" -f ($colItems.sum / 1MB) + " MB"
$xxx="{0:N2}" -f ($colItems.sum/ 1MB)
$str=Get-Content D:\trial.txt | ConvertFrom-Csv
"This is the function passed value"
$key = passval
echo $key
$flag=0
for($i=0; $i -lt $str.length; $i++){
if($str[$i].key -eq $key){
$flag=1
$flag
$value=$str[$i].value
}
}
$flag
if($flag -eq 0){$a = new-object -comobject wscript.shell
$b = $a.popup(“no match" )}
if($flag -eq 1){$a = new-object -comobject wscript.shell
$b = $a.popup(“ match" )}
if($xxx -gt $value){Remove-Item D:\00Newfolder\* -include *.jpg}
$colItems = (Get-ChildItem D:\00Newfolder -recurse | Measure-Object -property length -sum)
"{0:N2}" -f ($colItems.sum / 1MB) + " MB"
$xxx="{0:N2}" -f ($colItems.sum/ 1MB)