Accessing private members from powershell

Question:

I’m trying to get Uri to stop encoding ‘/’
As explained here:
GETting a URL with an url-encoded slash

But how to achieve the same in powershell ?

I’m trying to follow the route of accessing private property and changing it’s value but I can’t get it to work.

[Uri].GetProperties([System.Reflection.BindingFlags]::NonPublic) – returns nothing

Any ideas?

Answer:

This is working solution for PowerShell:

Thanks to google-api-dotnet-client path 🙂 please note, that there is some difference with .net 2.0, my code is working for > .net 2.0 (for <= 2.0 versions, the type of flagsValue object will be [Int32] instead of [Uint64])

Source:

Accessing private members from powershell by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply