Tagged: shares

Change settings on all shares

We are enabling BranchCache on a few servers… and with that you probably want to change the settings on the shares you have.

Why not use some Powershell when you have the chance. 🙂

Get-WmiObject -Class Win32_Share | Where-Object -FilterScript {$_.Name -notlike '?$' -and $_.Name -ne "ADMIN$" -and $_.Path -ne ""} | ForEach-Object {
	Write-Host "Updating $($_.Name) - $($_.Path)"
	$netShare = NET SHARE $_.Name /Cache:BranchCache
	If ($netShare -notlike "*completed successfully*") {
		Write-Host $netShare -ForegroundColor Red

Change /Cache:BranchCache to wahtever you want to do with the share.

Oh, btw… this works fine to do remote with something like this:

Invoke-Command -ComputerName SOMEREMOTESERVER -scriptblock {
	Get-WmiObject -Class  ... and the same code here ...