'Delete folder content for a folder for remote machine using powershell

I am having the below code to delete the contents for folder

$SB_Folder = "\\$hostname\c$\SB"
$Automation_Folder = "\\$hostname\C$\Scripts\"

Get-ChildItem -Path $SB_Folder -Include *.* -File -Recurse | Remove-Item -Force -Recurse
write-host "Content of $SB_Folder Deleted.." -BackgroundColor Green -ForegroundColor Black
Get-ChildItem -Path $Automation_Folder -Include *.* -File -Recurse | Remove-Item -Force -Recurse
write-host "Content of $Automation_Folder Deleted.." -BackgroundColor Green -ForegroundColor Black

It is executing without any error but when I check, it is not deleting all the folders.

Please let me know what I am missing here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source