Invoking Powershell modules on remote clients via package/command line

Hello Everyone -
I have two modules(functions) that i've written and tested successfully locally in my environment that give me Uninstall and Repair functionality on whatever the string contains. Both .psm1's are delivered via a SCCM pkg that lands both into folders
in the Modules directory. My issue is I can't seem to invoke this in a deployment scenario...as i'd like to deliver the "Invoke-command" using SCCM's command line to simply say...
Invoke-Command -scriptblock { Do-This "<string>" }
The above command works fine locally when...(exePol is set to Bypass).
1.)Modules have respective folders living in WindowsPowershell\Modules directory named xxxx.psm1
2.)Import-Module -name <path\name of module>
3.)Verify Modules are loaded(moduleType is script)
But when fabricating the folders\files above with SCCM, and running the Invoke-Command(in many different ways remotely), i recieve the cmdlet, program doesn't exist and has no idea what i'm talking about. Folders\Files for .psm1's are present and do
show when running Get-Module -Listavailable locally on targeted clients.
Maybe this is related to the Import-Module command and the context i'm trying to delivery it in?
I've tried multiple scenario's of...
A.) Psexec that launches powershell, followed by the Import-Module -name <path\name of module>
B.) .Bat file that launches powershell with the same Import-Module syntax
C.) PS1 that includes the same Import-Module line.
D.) Just straight from the command line of the Pkg/Program.
Has anyone tried this? Is there a better method when trying to deliver invoke-command on a module/function to a client via SCCM? 
TIA 

[I see that the you are running the powershell.exe and then importing the module in the command line for the Program you created in SCCM, so just importing the module will do the repair action for you ??]
Not sure how else i would run a Import-Module without calling upon powershell.exe. The reason for using Import-Module first is it only creates the abilty of whatever the module(function in this case) on the client. So if i can get the remote
Import-Module to work, which would then allow me in the future to use an Invoke-Command -scriptblock { Do-This "string" } on the clients. In this case its both an Uninstall and Repair function with an assortment of switches and arguements that will aide me
in the future in managing our apps. For me to use the Modules, i would need to Invoke-Command as that is how the functions are built.
Okey so the module does get dumped to the end machine.
Suppose you have a test machine TEST01 where the Test.psm1 file  (having Test-Function)is delivered through SCCM.
Then try this and tell if it works:
PS C:\> $session = New-PSSession -ComputerName TEST01
PS C:\> Invoke-Command -Session $session -ScriptBlock {Import-Module Test.psm1 }
PS C:\> Invoke-Command -Session $session -ScriptBlock {Test-Function #inside your Module}#Or Simply try below:
PS C:\> Invoke-Command -ComputerName TEST01 -ScriptBlock {Import-Modules Test.psm1;Test-Function #inside your Module}
I think what you are doing is below.....for the example am taking "webadministration" module:
PS C:\> Invoke-Command -ComputerName Server01 -ScriptBlock {Import-Module web*}
PS C:\> Invoke-Command -ComputerName Server01 -ScriptBlock {get-website}
The term 'get-website' 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.
+ CategoryInfo : ObjectNotFound: (get-website:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
+ PSComputerName : sdwuweb017
Point here is you need to import the module and work with it in an already opened session....If you specify a computername every time then PowerShell opens the Session does what you want it to do and tears down the session. To persist the importing of the
module it must be done in a session which we make using New-PSSession and then run the commands against that session.
I might have misunderstood the problem but this is what I have got so far.
Hope this helps
Knowledge is Power{Shell}.

Similar Messages

  • Launch remote control via a command line?

    Is is possible to launch a remote control session via a command line as well
    as the other "remote actions"?
    Thanks,
    Bryan

    On Wed, 29 Sep 2004 22:25:17 GMT, Bryan Miller wrote:
    > Is is possible to launch a remote control session via a command line as well
    > as the other "remote actions"?
    take a look at the online documentation which describes this..
    Marcus Breiden
    Please change -- to - to mail me.
    The content of this mail is my private and personal opinion.
    http://www.edu-magic.net

  • HT1428 How to change the account name in Mac OS X via a command line. I did a type-o on the account name. So instead of it saying "Company" it says "Comany"  for the account logon.

    How to change the account name in Mac OS X via a command line. When I created the account I mistyped the name. I have a management suite where I can execute remote scripts. I would like to run a script that changes the name from oldname to newname.
    None of these Macs have been used currently.
    Thank you,
    Brian

    If user account shortname, see Changing user account shortname

  • Can I manage resource designates via the command line?

    I would like to manage resource designates via the command line and
    the <i>"unires"</i> command does not seem to have this function. Could I use
    <i>"uniadmrights"</i>?
    # uniadmrights -e -add -resrc -n 10000
    <br>
    -e modify user rights, search filter
    <br>
    -add set user right on (-e only, default)
    <br>
    -resrc resource administration
    <p>
    The <I>uniadmrights</I> command is not able to assign designate rights. You can assign
    rights such as the ability to create and manage public and administration
    groups. The "Resource administration" flag exists so far only on the
    server side, and it is currently not used by the client. This is for future use.
    <p>
    There are two ways to assign a designate to a resource:
    <ol>
    <LI>Log on as the resource via the client. There are only a few commands
    available, one of them being the "Access Rights".
    <P>
    <LI>On the server side:
    <P>
    Edit the /users/unison/misc/resource.ini
    file and create a new section to specify the resource designate.
    <P>
    [DES]
    Designate0 = S=Lastname/G=Firstname
    <P>
    Run the unires command as follows:
    <P>
    % unires -mod "R=resourcename" -s DES 10000
    [sysOpPsw]
    </OL>
    <P>
    <B>Note:</B> The full resource name should be used eg. "R=Resource/N=1/CA=2/ID=2
    57"

    This sounds like a job for wget . You'll have to build and run it on Unix or Cygwin.
    You could also build a test suite to do this in various testing tools. You could even write a short Perl or Groovy script to do this, or a slightly longer Java class.

  • Fail to build SSIS/SSAS projects via VS2012 command line (devenv.exe) with SSDT BI tool installed

    Hello,
    I installed recently released SSDT BI tools for VS2012 and I can work on my existing SSIS/SSAS projects all well in VS2012. But when I try to build my SSIS/SSAS projects via the command line of VS2012, such as
    devenv.exe mySolution.sln /rebuild Release /out "C:\temp\buildLog.txt"
    I will get the error like below in the log file.
    Error: Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))
    Is this a known issue? If yes, any fix has been planned?
    Thanks
    Jimmy

    Hi Jimmy Jin,
    This sounds like .NET framework problem, please refer to:
    http://bchavez.bitarmory.com/archive/2007/08/23/catastrophic-failure-exception-from-hresult-0x8000ffff-e_unexpected.aspx
    http://bchavez.bitarmory.com/archive/2007/08/23/catastrophic-failure-exception-from-hresult-0x8000ffff-e_unexpected.aspx
    Thanks,
    Eileen
    If you have any feedback on our support, please click
    here
    Eileen Zhao
    TechNet Community Support

  • Setting proxy servers via the command line

    I am looking to find out how to set up the system to use http and https proxies via the command line instead of through system preferences. How do I do this. I have basic command line knowledge.

    This information is stored in a plist file and is easiest to manipulate with PlistBuddy. For example, to set the HTTP proxy name, use:
    /usr/libexec/PlistBuddy -c "Set NetworkServices:6CFBA910-E4A0-4418-82E5-66A6480EBC71:Proxies:HTTPProxy http://my.proxy.com" /Library/Preferences/SystemConfiguration/preferences.plist
    Note: 6CFBA910-E4A0-4418-82E5-66A6480EBC71 is a UUID and likely to be unique on each machine. I don't have another Mac handy to check this. If so, you'll need to do some heavy to find out which one is the interface you need to address.
    Try man PlistBuddy and/or a web search for more information on how this tool can be used.
    Try man PlistBuddy or a web searc for more info on using it.

  • True IP address for ARD remote client via IPObserver [newbie]

    I have had success managing LAN clients via ARD, but now my situation is different.
    I want to still be able to provide ARD support via a network address specific to a workstation from outside the LAN, and the IP address I have tried does not connect. I am deriving the address from the IP Observer utility that I had my client launch on their system. [it is not the obvious 192.168.1.xxx address from DHCP]. I have confirmed that the Sharing attributes are correct on the client system, although it might be a 2.2 version [running 3.1 admin]. Based on a test, I believe the IP Observer address is the internet IP location of the router [not the actual router LAN IP], not the client.
    The IP address indicates that it is in the correct domain [Roadrunner, NYC], but the client-specific address is inaccurate. Is it because the client is setup through a DHCP router and switch? will they need a static IP? Can they somehow reveal their station-specific IP via an iChat connection log? should I try to address the client though a different port?
    I am new to this extension of ARD, so bear with the obviousness of the query to some of you.
    thx - steve

    Hi, here is what you asked me for:
    webvpn
    enable inside
    enable outside
    csd image disk0:/securedesktop-asa-3.2.1.103-k9.pkg
    svc image disk0:/anyconnect-win-2.2.0128-k9.pkg 3
    svc enable
    cache
    max-object-size 5000
    group-policy DfltGrpPolicy attributes
    dns-server value X.X.X.X
    dhcp-network-scope X.X.X.X
    vpn-tunnel-protocol IPSec l2tp-ipsec svc webvpn
    default-domain value XXXXXX
    intercept-dhcp 255.255.255.XXX enable
    nac-settings value DfltGrpPolicy-nac-framework-create
    webvpn
    url-list value Lan_Applications
    svc keepalive none
    svc dpd-interval client none
    svc dpd-interval gateway none
    svc ask enable default webvpn
    customization value DfltCustomization
    tunnel-group DefaultRAGroup general-attributes
    authentication-server-group (outside) LOCAL
    authorization-server-group LOCAL
    authorization-server-group (outside) LOCAL
    dhcp-server XXX.XXX.XXX.XXX
    tunnel-group DefaultWEBVPNGroup general-attributes
    authentication-server-group (outside) LOCAL
    authorization-server-group LOCAL
    authorization-server-group (outside) LOCAL
    dhcp-server XXX.XXX.XXX.XXX
    authorization-required
    Best Regards,
    Jeyriku

  • Sending Reporting Services report via the command line

    I would like to either execute a subscription that sends a report via email on demand.  That or just email the report without having to edit the subscription date.  Can this be done from the command line?  I see there is the rs.exe utility
    that allows you to deploy reports and run configuration commands, but I would like to execute and email the report.  Is this possible?

    The easiest way to run a subscription manually is to run the agent job in SQL server that is associated to the subscription.  You'll need to know the subscription ID to do that.  So, you could either run it through SSMS, or if it needs to be in
    command line, interact with SQL Server via command line and do so.
    You can use the ReportService2010 API methods and and powershell script to identify the subscription ID
    https://msdn.microsoft.com/en-us/library/reportservice2010.reportingservice2010.aspx?f=255&MSPPError=-2147217396

  • VPN Client disconnection from command line

    Hi,
    I want to connect to IPsec VPN on ISA500 by VPN Client (v 5.0.07.0440, the last version, I think), using command line parameters.
    I can connect with the command:
    "%programfiles%\Cisco Systems\VPN Client\ipsecdialer.exe" -c -user myUser -pwd myPassword "MyConnectionEntry"
    but i don't know the command to disconnect from command lines.
    If I do
    "%programfiles%\Cisco Systems\VPN Client\ipsecdialer.exe" -?
    I obtain the list of parameters
    vpngui [-c | -sc [sd] [-user <username>] [-pwd <password> ! -eraseuserpwd]] <connection entry>
    but I don't unterstand what I have to do... I try every combination using -sd parameter (I think means for silent disconnect), but in every case I can only to show VPN interface  without disconnect anything...
    Can anyone help me?
    Thanks

    Prasath,
    This appears to be a data flow issue.  You need to look in the dataflow log file.  Your information indicates the project name is SAMPLES.xml, and the data flow ID is D20091213_014350765.  Look at the data flow log file in
    C:\dqxi\11_7\repository\configuration_rules\runtme_metadata\project_SAMPLES\D20091213_014350765
    Alternatively, you can temporarily replace the transactional reader and writter transforms with their corresonding batch transforms, and run the job from the Project Architect.  Any errors will be displayed in the Running window.
    Paul

  • How do I open a PDF to a specific page via the command line?

    Several questions about opening PDFs from the Mac OS X command line:
    1) How do I use the "open" command to open a PDF to a specific page? (I know I can open a document via: open doc_name.pdf)
    2) How do I use the "open" command to pass multiple arguments (page no, zoom scale, view mode, etc...) to open a PDF file in a specific manner?
    3) Does Preview handle the same parameters as Acrobat Reader? If not, what are the differences in options?
    I've spent hours searching for this answer and have come up dry. I've downloaded Adobe's "PDF Open Parameters" document -- it lists all of the parameters I need, however I can't get any of them to work from the command line.
    My goal: Open a PDF from the command line to a specific page. At first glance, I thought this would be simple to do and find -- however, after a lot of searching I haven't found an example on how to do it.
    Anyone have any experience doing this, and care to share?
    Much appreciated! ---> Kelsey

    I don't know of any way to do what you want using the 'open' command. It can probably be done with Applescript, which you could call from a shell script. The Preview application doesn't seem to be scriptable. I don't use Acrobat, so I can't tell you anything about that. Looking through the dictionaries of the apps I do have, it seems that Skim (another PDF viewer) has an AS 'page' class. Below are a couple of links that may get you started. Look for more specific guidance in Applescript forums.
    http://sourceforge.net/apps/mediawiki/skim-app/index.php?title=AppleScript
    http://links.tedpavlic.com/shell_scripts/skim

  • Package command line app with AIR app

    Forgive me if I seem completely dense, but I've been googling and forum finding and hair pulling all day on this.
    I wrote a command line application and I call it from my air application.  It all works just fine, but right now the location of the command line application is hard coded.  I want to know:
    1) What is the actionscript that allows me to refer my nativeProcess call to a an application that is packaged with the air app when I export?
    2) Where do I place the command line application in the file system of flash builder to bundle it with everything when I export?
    I realize it'll be different for mac and windows, but I need to do both.  I'm starting with the mac.  Right now as far as I know I can put the command line app in the source folder and that all ends up in the .app/contents/resources folder, but I'm not exactly sure how to reference that in actionscript or if I can or if I should?  I don't know.  Clue me in?

    Can you not use File.applicationDirectory.url as a base?

  • Method to restart Oracle Apps 11i OPP via Unix command line

    Hi All,
    Does any one knows if there any way to restart Oracle Apps 11i Output Post Processor (OPP) via the UNIX command line?
    Thanks

    Oracle-User wrote:
    Do you recommend that I set the profile option Concurrent: OPP Response Timeout to a higher value instead of increasing OPP Processes from 1 to 2? Yes.
    I'm thinking that increasing OPP Response Timeout to a higher value will not solve our issue as it seems that once we get our first OPP Timeout error, all of the requests that need the OPP fail. We've had this occur on a Saturday, which is a day where the volume of jobs that need the OPP is very low. The error you are getting is related to the timeout and it has nothing to do with the number of OPP processes you are running on. Please set this profile option and check then (after you bounce the OPP).
    Thanks,
    Hussein

  • Checkin activity via DTR command line tool

    Hello,
    I tried to maintain Access Control Lists in my DTR (Web AS 640, SP16), and now I have a weird situation:
    The NW Developer Studio shows that acl.xml unter /ws is checked out by user superadmin (that's correct as I used that one to maintain the ACLs), but it doesn't show any activity of superadmin.
    DTR command line tool shows the activity:
    >acts -U superadmin -o -uf
    ActualName      State
    act_w_system_config_active_u_superadmin_t_2006_06_06_12_42_33_GMT_6dca269b-9cb4-4d96-a663-fbe98c715265  Open
    But when I try to checkin the tool cannot find the activity any more:
    >checkin -a act_w_system_config_active_u_superadmin_t_2006_06_06_12_42_33_GMT_6dca269b-9cb4-4d96-a663-fbe98c715265 -w //
    system/config/active/ -U superadmin
    The specified activity does not exist. Please check and try again.
    Any idea how I can get rid of this lock on acl.xml in /ws?
    Thanks and best regards,
    Cornelia

    Hi,
    perhaps your release is higher equal to 711.
    From 7.11 onwards the DI command line tools are not provided in the eclipse/tools folder anymore.
    Instead they are provdided in the SCA file DICLIENTS.SCA  --> tcdicmd_tools~sda.sda
    Extract this SDA file from the SCA and then unzip it to get the DI command line tools.
    Hint: Once you rename the SCA to zip, you can extract with a normal extractor like winzip or winrar. Once you managed to extract the file tcdicmd_tools~sda.sda rename it also to zip and extract it too using normal extractor tools. Then you'll have a similar folder structure like on lower releases in the eclipse/tools folder was.
    You find the SCA file here:
    http://service.sap.com/patches --> Browse our Download Catalog - SAP NetWeaver and complementary products
    -- SAP NETWEAVER CE -- SAP EHP1 FOR SAP NW CE 7.1 -- Entry by Component -- NW Development
    Infrastructure --> DI CLIENTS 7.11
    (Obviously if you have 720 or 730 then adjust the path accordingly)
    See also https://cw.sdn.sap.com/cw/docs/DOC-109423
    I hope this helps.
    Best Regards,
    Ervin

  • How to initialize consumer from supplier via the command line ?

    We have a small directory that gets loaded from scratch every night.
    We also setted up replication to a couple of consumers (read only).
    The problem is that since the data is loaded everynight, we get compliants in logs "Replica has a different generation ID than local database"
    I can initialize the consumers via the gui. But how to do it from the command line from the master ? I know that an option is to do a db2ldif and then an ldif2db on the consumer but it's not an option for us.
    I also tried setting the nsds5beginreplicarefresh to start, but that doesn't seem to do a full init.
    There must be a way, as the gui actually does it.
    TIA

    Basically it's very simple. Supposing your replication is already setup and you reload data to your master. If you want the initialization pushed to all the replicas automatically, you can simply setup a flag in all the agreements. This flag is called nsDS5BeginReplicaRefresh.
    Please check the link:
    http://docs.sun.com/source/816-6699-10/confattr.html#18194
    nsDS5BeginReplicaRefresh
    Allows you to initialize a replica. This attribute is absent by default. However, if you add this attribute with a value of start, the server reinitializes the replica and removes the attribute value.
    Property
    Value
    Entry DN
    cn=ReplicationAgreementName,cn=replica,cn="suffixName",
    cn=mapping tree,cn=config
    Valid Range
    stop | start
    Default Value
    N/A
    Syntax
    DirectoryString
    Example
    nsDS5BeginReplicaRefresh: start
    Please note that this value is absent by default and will disappear whenever initialization to replica finished. Next time whenever you want it to happen again, use ldapmodify to set this flag up.
    Also, if you want this happen to all the master's replicas, you have to setup for all the agreements.
    I already tested and it turns out very magic.
    So what you should do is whenver your master get reloaded, when it gets finished, call ldapmodify to set the attribute to be "start".
    Hope it helps!

  • Rollbak of SPAM transaction via the command line

    Hi All,
    Can you please tell me, what command line can I exucute in order to rollbak the installation of an addon via SPAM?
    I can't not connect to my SAP solution manager via SAP GUI because the installation of the Addon failed.
    Thanks

    Once applied you cant uninstall the patch. So its better to open an OSS call with SAP to resolve your issue
    Thanks
    Prince Jose

Maybe you are looking for

  • How do I uninstall OS Lion and revert to Snow Leopard

    Hi all, I need to use Microsoft Office Mac Version in my work. And OS X Lion don't support that. I am desparate to know how do I unistall the OS X Lion, and revert to Snow Leopard so that I can resume working on my MacBook Pro. Please help.....

  • Organization is all screwed up...

    Hi! I haven't been on here for a while. Anyway, I'll get to the point. Basically, all my albums are set in order by "Album by Year." I have 3 Lord of the Rings Albums (the 1st 2 Complete Recordings and the Original Íoundtrack for Return of the King).

  • App Store must be built with Xcode 5.1.1 or later !

    I just upload a new binary to one of my apps to iTunes but I got the following error when I submit for review: Apps and app updates submitted to the App Store must be built with Xcode 5.1.1 or later, and iOS 7 SDK.

  • Permanent list of duplicates using drag & drop with iPhoto 11

    Every time I drag and drop a photo into iPhoto 11 from a website or other source, I'm asked if I want to also add every other photo I've ever dragged and dropped in. I can opt not to import duplicates, but is there a way to clear out or avoid this ev

  • Assign Assets value date bydefault as last year doc date.

    My scenario is : Assets Purchased date is 01-02.2009(which comes in last year) & we are posting it today. I keep default value date as doc date. But it comes by default  when i post in same fiscal yr.When i post with last yr doc date,then it takes to