Return powershell Function variable back to VBScript

Hey Scripting Guy,
I have a vbscript function that I use to call a Powershell Function. I need to return the powershell output back to the calling vbscript. I've tried different methods but I can only get return codes (either 1 or 0) back to the calling vbscript function and
not the string value itself.
Here is the code:
vbscript-
Function GetDomain(ByVal username As String) As String
Dim strCmd, ReturnDomain As String
Dim objshell
strCmd = "C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe -noexit -file c:\temp\Get-Infosec2.ps1" & "'" & username & "'"
Set objshell = CreateObject("Wscript.shell")
ReturnDomain = objshell.Run(strCmd)
GetDomain = ReturnDomain
Set objshell = Nothing
End Function
Powershell -
Function
Get-Infosec2{
[cmdletbinding()]
Param(
[parameter()]
[string]$name
# Add the Quest ActiveRoles snapin for easier AD management; but first check if it's already loaded.
$SnapIn
=
"Quest.ActiveRoles.ADManagement"
If
(Get-PSSnapin
$SnapIn
-ea
"silentlycontinue") {
write-Host
"Quest ActiveRoles plugin already loaded. Continuing ..."
elseIf (get-PSSnapin
$SnapIn
-registered
-ea
"silentlycontinue") {
write-Warning
"Quest ActiveRoles plugin registered but not loaded. Loading."
Add-PSSnapin
$SnapIn
else {
write-Host
"PS Snapin
$SnapInnot found."
-foregroundcolor
Red
Write-host
$ldapFilter
$domainname
=
Get-QADUser
-Identity
$name
-Properties
dn   
-SizeLimit

|
select-object
dn
$newstring
=
$domainname
-split ("DC")
$newstring1
=
$newstring[0]
$newstring2
=
$newstring[1]
$domainname
=
$newstring2.Substring(0,$newstring2.Length-1)
$domainname
=
$domainname.Substring(1)
$domainname
 The result that I am trying to achieve is getting the value of $domainname back to the calling vbscript function.
Any Idea what I am doing wrong?

Why don't you just use VB to get the domain.  You can get it directly.  No need for PowerShell.
This is a scripting forum and you are codeing in VB not VBScript. You need to post your questions in the VB developers forum.
In VB.Net you can just use the CurrentDomian static method of the DirectoryServices class.
¯\_(ツ)_/¯

Similar Messages

  • Use of Return and Notify_url variables offered by PayPal

    I have been integrating PayPal into my application (ASP NET MVC) where I made some analysis about PayPal (went through their documentation about the integration). Created a PayPal sandbox account and can transfer the amount.What I want to know is about the `return` and `notify_url` variables. I have enabled `auto return` in my account and also enabled `PDT`. My form variable is like this:<input type="hidden" name="notify_url" value="http://localhost:xxx/xx/Notify">
    <input type="hidden" name="return" value="http://localhost:xx/xx/Return">As I have surfed in net, what they state about `Return` and `notify_url` is:> The "return" URL to which PayPal redirects buyers’ browser after they complete their payments. For example, specify a URL on your site that displays a “Thank you for your payment” page. Default is nothing is specified – PayPal redirects the browser to a PayPal webpage. Note, you must have "Auto Return" enabled in your Account Profile settings in order for this variable to work.
    >PayPal returns data back to your site via what they call IPN. Its really just a callback to a URL you specify. You can set this URL via the variable `notify_url` you can send to PayPal.From the above quotes what I understand is that PayPal will post `IPN` variables to `notify action` once the payment done before auto redirecting to the page I set (I mean customer may go the application page or they may close the session).But only return action alone hitting not the `Notify_url`.Correct me if I misunderstood the concept and let me know if it was still Unclear.

    Yes, it's not present in the code I have posted but I have tried this as well.
    It didn't work, as expected, because soap/axis is on top of http and not https and because my proxy uses http as well (or at least that's what I have learned so far).
    In fact, I have tried all combinations between http.\*, https.\*, and Authenticator without success.
    I think the problem is more soap/axis related. The solution for axis2 seems somewhat 'trivial' (and well explained over the web) while it's not for axis1.
    Regards
    Rob
    Edited by: RobR on Nov 29, 2007 4:37 AM
    Edited by: RobR on Nov 29, 2007 9:56 AM

  • Why can't I run a powershell file I created from a powershell function

    Ok so admittedly I am still learning a lot about powershell so this may have a very easy explanation/solution
    So I have this script file and this is it in its entirety 
    function Add-DriveFunctions($Provider, $Path)
    foreach ($Drive in $Provider.Drives)
    if ((Get-Command | where Name -eq "$($Drive.Name):") -eq $null)
    [String]"function $($Drive.Name):() {Set-Location $($Drive.Name):}" | Out-File $Path -Append
    $Path = C:\Temp\test.ps1
    """Adding Drives""" | Out-File $Path
    foreach ($Provider in Get-PSProvider)
    Add-DriveFunctions -Provider $Provider -Path $Path
    C:\Temp\test.ps1
    When I run it it happily creates the ps1 file whose content looks like this
     "Adding drives"
    function Alias:() {Set-Location Alias:}
    function Env:() {Set-Location Env:}
    function Function:() {Set-Location Function:}
    function HKLM:() {Set-Location HKLM:}
    function HKCU:() {Set-Location HKCU:}
    function Variable:() {Set-Location Variable:}
    But the last line to actually load and run the ps1 file does nothing
    even calling C:\Temp\test.ps1 does nothing
    but if I load the file into ISE and run it from there
    it works.
    Unless I'm completely missing something I would think being able to call other ps1 files from other ps1 files or the command line would be a pretty important part of powershells flexibility.
    So if anyone could tell me why in this case it does not work I would greatly appreciate that
    Cheers,
    Quidquid latine dictum sit, altum videtur

    Ok i'm a little confused 
    in ISE if I write a ps1 file and i have just a function in it not anything calling that function when i run or debug it loads that functions definition into the current session and then from my console i can access my function. so Is that what the . is supposed
    to do?
    When i tried the . I get this
    The term '.C:\Temp\test.ps1' is not recognized as the name of a cmdlet, function, script file, or operable 
    program. Check the spelling of the name, or if a path was included, verify that the path is correct and try 
    again.At C:\Users\rjs012978\Downloads\FunctionTest.ps1:20 char:1
    + .C:\Temp\test.ps1
    + ~~~~~~~~~~~~~~~~~
        + CategoryInfo          : ObjectNotFound: (.C:\Temp\test.ps1:String) [], CommandNotFoundException
        + FullyQualifiedErrorId : CommandNotFoundException
    Also I know i can do that with the mono letter drive but working on a network over half the alphabet is taken up by my actual network mapped drives.
    And the provider i'm writing is connecting to multiple Space IDs that i'm making into my drives so I would quickly run out of letters.
    proof of concept i know what i'm doing works if I do it manually
    I know it's kind of silly but for me the amount of time i spend in powershell especially administering SCCM, the registry and AD being able to just type hklm: and hitting enter is a huge time save over the long haul than typing cd hklm: even though it's
    just 3 more characters
    Quidquid latine dictum sit, altum videtur

  • Calling function from Backing Bean or JSP page

    We are on Jdeveloper 10.1.3.3.0, ADF Faces, JSF Faces .., Currently there is a function call from Javascript event (onmouseover) in the JSP page. I want to call this function from a backing bean or JSP page, as I have to pass some values to this function.
    For Ex., I have a function call like return submit('A','B','Test'); on the Javascript event (onmouseover) in jsp page. I want to remove this function from the javascript event and call from backing bean or jsp page to pass some values into the submit() function. I appreciate if anyone can give some example of how to call this function from backing bean or jsp page in the <SCRIPT> or <SCRIPTLET>
    Thanks,
    Ram

    A use case would be helpful so that we can get a better idea of what you want to do.
    As a general rule, there is no way to call a client side Javascript function from a backing bean, which is server side. However, there are ways to inject information from a backing bean into your Javascript call. For instance, I have an application that uses Google Maps API. It has an onload call to a Javascript function that builds the map and designates it's center point. The center point comes from a backing bean as latitude and longitude properties. So here is my body tag:
    <afh:body onload="initialize(#{backing_searchResults.latitude},#{backing_searchResults.longitude},#{searchCriteria.distance})"
              onunload="GUnload()">onload calls the Javascript function called initialize, and passes the latitude, longitude, and distance from the bean. Is the function really being called from my backing bean? No - the parameters are hard coded into the onload event code when the page is rendered. Does it do the job? Sure it does.

  • Function call another function variable

    Is it possible to call another function variable?
    Below is my Script:
    f2();
    function f1() { 
      var v2 = 1; 
    function f2(v2) { 
      var v3= 2; 
      alert(v2);

    Hi creativejoan0425,
    Some additional notes:
    > Is it possible to call access another function variable?
    No, it isn't. A local variable only lives in the scope of the function (body) where it is declared. In that sense any local variable should be considered private—in OOP terms.
    pixxxel schubser's solution is based on setting a global scope for the variable myA, so it is visible from every place of your code.
    Another solution could be implemented using JS closure mechanism. You can create a local scope (in an anonymous function which is executed once) then return your main function and additional helpers from that scope. All inner functions have then access to the local variables that have been declared in the scope. For example, you can create your function f1 and attach a getter function to it, as follows:
    var f1 = (function(/*anonymous*/__)
        // Local variable to be nested in the closure
        var v1;
        (__ = function(/*optional init value*/x)
            // Here is your *actual* function
            // do what you want with v1
            v1 = 'undefined'!=typeof x ? x : Math.random();
        ).getVar = function()
            // Here is your getter
            return v1;
        return __;
    var f2 = function()
        alert( f1.getVar() );
    // Process
    f1('init');
    f2();           // => 'init'
    f1();
    f2();           // => some random number
    f1();
    f2();           // => another random number
    // etc
    This way v1 remains almost private but the outer code can read it through f1.getVar().
    Anyway this seems to me a complicate approach for a basic script that probably does not require high security level. Another option, really easy to set up, is to use the fact that a function is an object. Instead of declaring a local variable, just handle v1 as a (public) member of f1, as follows:
    var f1 = function F(/*optional init*/x)
        // Do something with F.var
        F.v1 = 'undefined'!=typeof x ? x : Math.random();
    var f2 = function()
        alert( f1.v1 );
    f1('init');
    f2();          // => 'init'
    f1();
    f2();          // => some random number
    f1();
    f2();          // => another random number
    That's it!
    > why every function need to return?
    No, return is not required. By default, any function that has no return statement will simply return undefined.
    @+
    Marc

  • FUNCTION Variable within Data Template

    Hi Im calling a function within my sql and i want to use the result as a bind variable.... here goes...
    Data Template...... XML
    <sqlStatement name="Q1">
    <![CDATA[select function_name(ppp.id) the_main_one,
    :the_main_one + 10 new_value
    from per_ppp]]>
    </sqlStatement>
    I get null value .... but from the_main_one i get a value..... any ideas... i checked for number and nvl(,0) and all that no luck
    is there a grouping thing involved here... where as i need to call the function from within another sql statement...

    It can be done.
    Step 1: Setup package.
    Step 2: Create a global variable for your function value
    Step 3: Before the calling function returns the value, set a global variable (placeholder)
    Step 4: Create a new function that returns the global variable, make sure it's after the first function call. Returning the value you might want to reset the global variable to null....
    Your good to go.
    Ike Wiggins
    http://bipublisher.blogspot.com

  • Procedure parameter of type returned by function

    Hi there
    I want to know if it's possible to pass a parameter to procedure of type returned by function
    Something like that
    pocedure test(x in varchar2
    ,y in my_function(param)
    )

    Definitely don't fullish yourself ;-)
    AFAIK you cannot declare a variable based on the return type of a function.
    Perhaps though you are looking for SUBTYPEs.
    SQL> SET SERVEROUTPUT ON;
    SQL> DECLARE
      2    SUBTYPE subtype_name IS VARCHAR2 (30) NOT NULL;
      3
      4    PROCEDURE procedure_name (
      5      parameter_name IN subtype_name)
      6    IS
      7    BEGIN
      8      DBMS_OUTPUT.PUT_LINE (parameter_name);
      9    END;
    10
    11    FUNCTION function_name (
    12      parameter_name IN DATE)
    13      RETURN subtype_name
    14    IS
    15    BEGIN
    16      RETURN TO_CHAR (parameter_name, 'DAY');
    17    END;
    18
    19  BEGIN
    20    procedure_name (function_name (SYSDATE));
    21  END;
    22  /
    THURSDAY
    PL/SQL procedure successfully completed.
    SQL>

  • Returned by function MAPIResolveNames

    Hello all.  We have a customer that is trying to export a report and email it.  I will give you the rundown.
    Windows 7
    CR 9 SP 7
    Latest Windows SP
    Outlook 10
    We are getting an error, ERROR 2147500037 RETURNED BY FUNCTION <MAPIRESOLVENAME>
    I read the other threads and didn't seem to be anything in there for CR 9.  Any help would be greatly appreciated.

    Hello,
    Correct. There is no fix for Cr 9 since it's been out of support for 5 years or so.
    Only option is to upgrade to CR 2008 and apply Fix Pack 3.1. Microsoft deprecated simple MAPI API's in Window version 6.1 ( 7 and Server 2008 ) Cr had to update the export dll to use the Extended API set of instructions which is why there is no fix for old versions of CR that had no concept of the Extended set.
    If they can't upgrade then only other option is to ask Microsoft to put the simple MAPI functionality back into all the Products they removed it from. They broke backward compatibility.
    Thank you
    Don

  • Error 2147500037 returned by function MAPIResolveName

    I am getting this error when i am sending  a mail
    MAPI Destination
    Error 2147500037 returned by function <MAPIResolveName>
    its Crystal Report 8.5 with SP3
    Windows Server 2008 R2 Standard
    Windows LIve Mail
    Please suggest

    Upgrade to Crystal Reports 2008 SP 3 and install [Fix Pack 3.5|https://smpdl.sap-ag.de/~sapidp/012002523100006341722011E/cr2008fp35.exe] and then it supports Windows Office 2007 Extended MAPI API's. Microsoft deprecated the Simple MAPI API's in in Office 2007 and above.
    Not supported in CR 8.5, it is 10 years old. Only other option is to ask Microsoft to add the simple MAPI API's back into their new Office Products that use MAPI.
    Thank you
    Don

  • How to call a Javascript function from backing bean without any event

    Hi,
    Someone knows how to call a Javascript function from backing bean without any event ?
    thanks

    Please review the following thread:
    ADF Faces call javascript
    Luis.

  • I'm new to Apple (MacBook Pro). Had a PC before.  First day I had the new Apple, somehow I lost the return arrow to go back to an original page (if that makes sense).

    First day I had my Apple I was on Craig's List looking at an item and somehow I deleted the return arrow to go back to the original list. So now when I'm on a site, there's no arrow to go back and I have to close and start all over.  How do I get the return arrow that I believe is on the left side of the screen?  I've never had an Apple, so all of this is new to me.  Thanks!  Jo

    If I understand your question, you need to select View > Customize Toolbar from the Safari menu bar. Drag the back/forward arrows into the toolbar wherever you want them, then click Done.
    You can also go back to the previous page by pressing command-left arrow on the keyboard.

  • Reason: Error in sieve filter: Unknown function/variable found: church around input line 79 [ stop; } require " f^ileinto"; if header ]

    My wife's email has been getting filled with hundereds of emails with this in them this morning. I don't see where anyone else is having this problem today, but I wanted to see if it's on iCloud's end or ours.
    Processing errors occurred during delivery:
    Recipient address: [email protected]
    Reason: Error in sieve filter: Unknown function/variable found: church around input line 79 [ stop; } require " f^ileinto"; if header ]
    Delivery processing continued in spite of these errors.
    Reporting-MTA: dns;ms21034.mac.com (tcp_intranet-daemon)
    Arrival-date: Tue, 13 Mar 2012 07:33:18 +0000 (GMT)

    My Wife and I both have an Ipad and an iPhone, I use an iMac and my wife a MacBook Pro.
    I have this problem with all my devices.
    My wife has NOT got this problem.
    We both use a [email protected] email acount.
    Just compared the settings:
    For "Incoming server" I have p03-imap.mail.me.com
    My Wife has p02-imap.mail.me.com .... and has not got this problem.
    I have setup a new rule for incoming mails (for the meantime):
    move all incoming emails from [email protected] to trash and delete it.
    Works fine for now,......until APPLE deals with the problem.
    Message was edited by: RTONLINE

  • How to call javascript function in back bean of jsf

    hi,
    i am trying to call java script function in back bean but not done. Is there any code for call javascript function in bean file.

    Java runs at server side.
    JSF produces HTML output.
    Server sends HTML output to client.
    Java stops running.
    HTML runs at client side.
    JS starts to run in HTML.
    Clear? Java is a server side language. JS is a client side language. To run JS using JSF, simply print it out to the HTML so that it get invoked when the HTML runs.

  • Call function inside of call function in back ground task

    Hi Friends,
       I am calling one function in back ground task. that is executing after save of the transaction. And inside of that transaction i am calling one more function but in debugging the cursor is not going inside of that function. What could be the reason. Please help me.
    Thanks a lot in advance.

    Hi,
        Inside of the first function any way i will come after save
    using update task debugging. Once it reach inside of firt function and if i press f5 then second function is coming and if i press f5 there then it is coming out of the function and it is not going inside. The second function is called directly not in back ground.
    Thanks..

  • Call transaction inside of call function in back ground task

    Hi,
        Is it possible to use call transaction statemement inside of call function in back ground task. I am getting error if i use the same. Any help will be highly appreciated.

    Hi,
    I don't think this is possible. The call goes into error in SM58, what you can try to do is after the function is called, you can submit the program RSARFCEX by setting the user name as sy-uname and other parameters as * and set all the checkboxes.
    regards,
    Advait

Maybe you are looking for

  • Mssql single quote problem!

    Hi, I user servlet to update MS SQL2000. My problem is there is a single quote inside a text string! I can't use double quote for string, as it is not a valid statement for MSSQL. I need to use single quote, but there is single quote inside the strin

  • Method not found error when creating COM object

    i am trying to initiate a COM object with CF and Imagemagick on windows 2003. when i initiate the object i get the error "The selected method convert was not found." if i do a dump of the method in the COM object but i cant call it. what am i missing

  • How install Solaris 2.5.1 and Windows Together

    Hi, We�ve a registered copy of Solaris 2.5.1 and we can�t install solaris and windows in the same Hard disk. I�ve been trying since two weeks. I can�t found a document that help me with this task. Please, help me with the directions to do that or try

  • Performance: Mathematical functions

    I'm a recent convert to Oracle and need some advice. Scenario: 1. Our client has a web application written in Java that queries an Oracle database to extract a list of stores based on their location. 2. The client approached us to rewrite the applica

  • Error in libolapapi9.so

    I've installed 9.2.0.3 64 bit on SPARC Solaris 9 (9/02) When I run bi_check config I get this error: <BICheckConfig version="1.0.0.0"> <Check key="JDEV_ORACLE_HOME" value="D:\jdev92031"/> <Check key="JAVA_HOME" value="D:\jdev92031\jdk"/> <Check key="