Freigeben über


Some examples of cmdlets making life easier

Couple things I needed to do today - you can see how they were much simpler thanks to a couple of cmdlets I had written in the past:

  • delete shelvesets I didn't need any more.
    • Since I only wanted to keep a few that I had made today, I just checked the creation date against today.
    • Get-TfShelveset | ?{ $_.creationdate -lt [datetime]::today } | %{ tf.exe shelve /delete /i $_.name }
  • delete workspaces where none of the mapped local folders exist any more
    •  Get-TfWorkspace | %{ 
       $oneexists = $false
        $_.Folders | %{ $oneexists = $oneexists -or [io.directory]::exists($_.localitem) }
        if (-not $oneexists) { 
              "Deleting $($_.DisplayName)" 
              tf.exe workspace /delete /i $_.Name
       } else { 
            "Keeping $($_.DisplayName)" 
       } 
      }