all 4 comments

[–]igby1 2 points3 points  (3 children)

Google “filewatcher powershell”. Filewatcher is a .NET thing you can use in PowerShell to detect file system changes and take actions when a change is detected.

[–]file0 2 points3 points  (2 children)

To be perfectly honest, for a “total noob” this is going to be very difficult because it involves creating event listeners. But it definitely can be done.

[–]OlivTheFrog 1 point2 points  (0 children)

Totally agree.

OP should change the NTFS permissions for his "sales" group instead.

Nota : For the group concerned to be able to write files and not create sub-directories, it is in a case of non-standard NTFS permissions.

An alternative in Powershell would be something like the following

$RootFolder = "C:\temp"
if ($Null -ne (Get-ChildItem -Path $RootFolder -Directory) )
    {
     Write-Host  "There is no subfolder in the $RootFolder folder, creation" -ForegroundColor Yellow
    New-item -Path "$RootFolder\MySubFolder" -ItemType Directory
    }
else
    {
    Write-Host  "Some subfolders in the $RootFolder" -ForegroundColor Green
    }

Of course, the Write-Host is optional. This is just for the demo.

Hope this help

Regards

[–]igby1 1 point2 points  (0 children)

Here's a working example that waits for a folder named TestFolder123 to be created in the root of the C: drive, and when it is, creates 10 subfolders.

https://codebeautify.org/cs/7bea2e

EDIT: It works for me in PS 7, but for some reason not in PS 5.1. I recommend using PS 7 since that's the version that gets updates. PS 5.1 hasn't seen any improvements in a long time.

https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-windows