Functions/Set-OnedriveItemAvailability.ps1
function Set-OnedriveItemAvailability { [CmdletBinding()] param ( [Parameter()] [ValidateSet("Online", "Offline", "FreeUpSpace")] [string] $Setting = "Offline", [Parameter()] [string] $Path = ((Get-Location).Path), [Parameter()] [string] $Filter ) $loc = Get-Location Set-Location $Path if ($Filter) { switch ($Setting) { "Offline" { attrib +P /S /D $Filter } "Online" { attrib -P /S /D $Filter } "FreeUpSpace" { attrib -P +U /S /D $Filter } } } else { switch ($Setting) { "Offline" { attrib +P /S /D } "Online" { attrib -P /S /D } "FreeUpSpace" { attrib -P +U /S /D } } } Set-Location $loc } |