Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - 64 bit binary or (-bor operator)?

Reply
 
Old 03-03-2008   #1 (permalink)
l0b0


 
 

64 bit binary or (-bor operator)?

Hi all,

Anyone know of a trick to get PowerShell to do "binary or" on a 64-bit
integer (type System.UInt64)? I need it to set the anonymous
permissions on a SharePoint site, as such:
$siteCollection.RootWeb.AnonymousPermMask64 =
[Microsoft.SharePoint.SPBasePermissions]::BrowseDirectories -bor
[Microsoft.SharePoint.SPBasePermissions]::Open -bor
[Microsoft.SharePoint.SPBasePermissions]::OpenItems -bor
[Microsoft.SharePoint.SPBasePermissions]::UseRemoteAPIs -bor
[Microsoft.SharePoint.SPBasePermissions]::ViewListItems -bor
[Microsoft.SharePoint.SPBasePermissions]::ViewPages

--
Victor

My System SpecsSystem Spec
Old 03-03-2008   #2 (permalink)
Oisin (x0n) Grehan [MVP]


 
 

Re: 64 bit binary or (-bor operator)?

On Mar 3, 4:03*am, l0b0 <victor.engm...@xxxxxx> wrote:
Quote:

> Hi all,
>
> Anyone know of a trick to get PowerShell to do "binary or" on a 64-bit
> integer (type System.UInt64)? I need it to set the anonymous
> permissions on a SharePoint site, as such:
> $siteCollection.RootWeb.AnonymousPermMask64 =
> [Microsoft.SharePoint.SPBasePermissions]::BrowseDirectories -bor
> [Microsoft.SharePoint.SPBasePermissions]::Open -bor
> [Microsoft.SharePoint.SPBasePermissions]::OpenItems -bor
> [Microsoft.SharePoint.SPBasePermissions]::UseRemoteAPIs -bor
> [Microsoft.SharePoint.SPBasePermissions]::ViewListItems -bor
> [Microsoft.SharePoint.SPBasePermissions]::ViewPages
>
> --
> Victor
Try:

$siteCollection.RootWeb.AnonymousPermMask64 = `
"BrowserDirectories, Open, OpenItems, UseRemoteAPIs,
ViewListItems, ViewPages"

PowerShell is able to coerce this string to a flags decorated enum.
For ordinary enums, just use a single string with the name of the
value.

Hope this helps,

- Oisin
My System SpecsSystem Spec
Old 03-04-2008   #3 (permalink)
Jon


 
 

Re: 64 bit binary or (-bor operator)?

Oisin's given you I suspect the best solution, but in terms of doing a
64-bit bor, one way would be to convert each of the numbers to binary eg

$binary_int1 = [Convert]::ToString($int1,2).PadLeft(64,"0")

create bit arrays into which you put your ones or zeroes (boolean true or
false)

$BitArray_int1 = new-object System.Collections.BitArray(64)

and then use the 'Or' method of the bit array with another such
construction.

Then convert the result back.

Another approach might be to split each of the 2 64-bit integers in two -
higher and lower 32 bits and then compare the higher 32-bits of one integer
with the higher 32-bits of the other, and similarly the lower portion. Then
recombine the results.

Sorry if that's a bit rambled, and I've missed out a few of the 'bor-ing'
details (sorry couldn't resist ;-) ) but it may give you some ideas.

--
Jon


"l0b0" <victor.engmark@xxxxxx> wrote in message
news:58015422-323a-4ae0-9f38-6bec5c124865@xxxxxx
Quote:

> Hi all,
>
> Anyone know of a trick to get PowerShell to do "binary or" on a 64-bit
> integer (type System.UInt64)? I need it to set the anonymous
> permissions on a SharePoint site, as such:
> $siteCollection.RootWeb.AnonymousPermMask64 =
> [Microsoft.SharePoint.SPBasePermissions]::BrowseDirectories -bor
> [Microsoft.SharePoint.SPBasePermissions]::Open -bor
> [Microsoft.SharePoint.SPBasePermissions]::OpenItems -bor
> [Microsoft.SharePoint.SPBasePermissions]::UseRemoteAPIs -bor
> [Microsoft.SharePoint.SPBasePermissions]::ViewListItems -bor
> [Microsoft.SharePoint.SPBasePermissions]::ViewPages
>
> --
> Victor
My System SpecsSystem Spec
Old 03-05-2008   #4 (permalink)
l0b0


 
 

Re: 64 bit binary or (-bor operator)?

Thank you both! Turns out this didn't solve my actual problem though:
How to get anonymous access to SharePoint web services: <http://
groups.google.com/group/
microsoft.public.sharepoint.windowsservices.development/browse_thread/
thread/f9893dde5bf19067/960631001fcc5053>

On Mar 5, 12:43 am, "Jon" <Email_Addr...@xxxxxx> wrote:
Quote:

> Oisin's given you I suspect the best solution, but in terms of doing a
> 64-bit bor, one way would be to convert each of the numbers to binary eg
>
> $binary_int1 = [Convert]::ToString($int1,2).PadLeft(64,"0")
>
> create bit arrays into which you put your ones or zeroes (boolean true or
> false)
>
> $BitArray_int1 = new-object System.Collections.BitArray(64)
>
> and then use the 'Or' method of the bit array with another such
> construction.
>
> Then convert the result back.
>
> Another approach might be to split each of the 2 64-bit integers in two -
> higher and lower 32 bits and then compare the higher 32-bits of one integer
> with the higher 32-bits of the other, and similarly the lower portion. Then
> recombine the results.
>
> Sorry if that's a bit rambled, and I've missed out a few of the 'bor-ing'
> details (sorry couldn't resist ;-) ) but it may give you some ideas.
>
> "l0b0" <victor.engm...@xxxxxx> wrote in message
>
> news:58015422-323a-4ae0-9f38-6bec5c124865@xxxxxx
>
Quote:

> > Anyone know of a trick to get PowerShell to do "binary or" on a 64-bit
> > integer (type System.UInt64)? I need it to set the anonymous
> > permissions on a SharePoint site, as such:
> > $siteCollection.RootWeb.AnonymousPermMask64 =
> > [Microsoft.SharePoint.SPBasePermissions]::BrowseDirectories -bor
> > [Microsoft.SharePoint.SPBasePermissions]::Open -bor
> > [Microsoft.SharePoint.SPBasePermissions]::OpenItems -bor
> > [Microsoft.SharePoint.SPBasePermissions]::UseRemoteAPIs -bor
> > [Microsoft.SharePoint.SPBasePermissions]::ViewListItems -bor
> > [Microsoft.SharePoint.SPBasePermissions]::ViewPages
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
-ne operator PowerShell
Powershell Operator PowerShell
-f operator PowerShell
What does the $() operator do? PowerShell
How to embed manifest in TCL binary? - mt.exe corrupting my binary Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46