I have been writing a script to gather some permission information from out main Data drives. We have a lot of paths longer than 255 characters. Powershell’s default Get-Acl cmdlet cannot handle long file paths and errors.
Whilst looking for a solution, I came accross this .NET library which is supposed to help with issues related to long file names.
Considering I found it on nuget.org and I’m running Windows 10 (Windows Management Framework v5) I thought about using the new built in package management tool – previously called OneGet. The idea is simple – copy the linux package managers. Great, its just what Windows has needed always! I am not going to fully explain the concept behing a packagement tool in this post. This post has a great explanation.
So how do we install this Experimental library from Nuget.org? First, I tried the following command :
Install-Package Microsoft.Experimental.IO Install-Package : No match was found for the specified search criteria and package name 'Microsoft.Experimental.IO'. At line:1 char:1 + Install-Package Microsoft.Experimental.IO + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage
Hmmm, I guess the nuget repository isn’t loaded by default – how do we load a repo? Register-PackageSource https://technet.microsoft.com/en-us/library/dn890701.aspx Got a bit lucky here, the example at the bottom of the TechNet documentation for this cmdlet is how to load the nuget repo. I made one change, only a fool would use http instead of https.
Register-PackageSource -Name Nuget.Org -Location https://www.nuget.org/api/v2 -ProviderName nuget Name ProviderName IsTrusted IsRegistered IsValidated Location ---- ------------ --------- ------------ ----------- -------- Nuget.Org NuGet False True True https://www.nuget.org/api/v2
Now the repo is loaded we can install the Experimental.IO library. I ran the following command to list the packages containing “experimental”
find-package -contains Experimental | out-gridview