Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

64 bit binary or (-bor operator)?

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 03-03-2008   #1 (permalink)
l0b0
Guest


 

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]
Guest


 

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
Guest


 

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
Guest


 

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
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
-f operator Tibor Soos PowerShell 3 05-28-2008 07:36 AM
What does the $() operator do? Kevin Buchan PowerShell 3 02-08-2008 02:05 PM
Suggestion: 1 new operator (well, maybe 6...) dreeschkind PowerShell 10 07-12-2007 11:34 AM
-f Format Operator Guy Thomas PowerShell 7 06-13-2007 01:15 PM
How to embed manifest in TCL binary? - mt.exe corrupting my binary Kshitij Vista General 0 02-14-2007 04:42 PM


Update your Vista Drivers Update Your Drivers Now!!

Vistax64.com 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 2005-2008