I'd like to loop to commands with powershell for creating local share and remove it after 5 minutes. Then wait 1 minute and create the share again.. Then after 5 minutes to remove it and after another one minute to create it again and so on and so forth ..
Got those two:
$FolderPath = "D:\proxy"
$ShareName = "proxy"
$Type = 0
$objWMI = [wmiClass] 'Win32_share'
$objWMI.create($FolderPath, $ShareName, $Type)
Start-Sleep -s 60
Get-WmiObject -Class Win32_Share -Filter "Name='proxy'" | Remove-WmiObject
Start-Sleep -s 60
$objWMI = [wmiClass] 'Win32_share'
$objWMI.create($FolderPath, $ShareName, $Type)
But it's not looping. It stops after end of file.