Convert from Powershell to vb.net

Welcome Forums General PowerShell Q&A Convert from Powershell to vb.net

This topic contains 1 reply, has 2 voices, and was last updated by

 
Senior Moderator
1 week, 3 days ago.

  • Author
    Posts
  • #165196

    Participant
    Topics: 1
    Replies: 0
    Points: 12
    Rank: Member

    Good Afternoon,

    i'm sorry to ask, but i'm really noob with powershell and i'm struggling with this bunch of code,  this  will be a part of a link that is generated(see below).

    it convert our guid document saved for example ""9999999999199012537"

    in an OID that will be a part of the string that composed this website, in this way it works, but i need to convert it to vb, and you will say why? because i want to integrate on my consol application for an internal use.  Do you have any Idea?

    $link= "http://test.$branch.net:7408/edoc/main?object=document&method=stream&watermark=true&OID="+ (ConvertTo-Oid -guid $eDocTable[$eDocIndex].G_U_I_D)

    Param([Parameter(Position=0, Mandatory=$true)]  [String] $guid)
    
    $guidClass = (($guid -shr 60) -band 15)
    
    $guidID    = (($guid -band 0x0FFFFFFFFFFFFFFFL) -shr (60 - ($guidClass * 4)))
    
    $guidValue = $guid -band (0x0FFFFFFFFFFFFFFFL -shr ($guidClass * 4))
    
    #Assemble result
    
    if (($guidClass -eq 0) -and ($guidID -eq 0)) {
    
    # Handle special case
    
    return "0-" + '{0:X}' -f $guidValue
    
    }
    
    else{
    
    return ("" + ('{0:X}' -f $guidClass) + "" + ('{0:X}' -f $guidID) + "-" + ('{0:X}' -f $guidValue))
    
    }
    
    }
    
    

    Thank you,

    have a great day!

  • #165748

    Senior Moderator
    Topics: 8
    Replies: 963
    Points: 3,065
    Helping Hand
    Rank: Community Hero

    Yes, why ? Can you give more details on why VB is required here, somebody might be able to help you in that.

You must be logged in to reply to this topic.