Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The problem you are facing is that you need to be able to set the PSSession for all of the imported functions implicitly. To do that you need to be able run the <code>Set-PSImplicitRemotingSession</code>function. </p> <p>Unfortionatly that function is not being exported so you cannot access it. What you need to do to resolve this is crack open the PSM1 file and add that function to the end of <code>$script:ExportModuleMember</code>. Now when you import the module that function will be abilable to set your PSSession for all of the functions.</p> <p>Here is what your powershell or scripts will need to run to be able to use any of the imported modules.</p> <pre><code>Import-Module "C:\Credentials.psm1" Import-Module "C:\ExportedPSSession.psm1" $Cred = Import-Credential -path C:\Cred.xml $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://ps.outlook.com/powershell/" -Authentication Basic -AllowRedirection -Credential $Cred Set-PSImplicitRemotingSession -PSSession $Session -createdByModule $True #You can now run any of the imported functions. </code></pre> <p><strong>Credentials.psm1</strong> <em>Beware! Anyone who can load the xml file can now impersonate you!</em></p> <pre><code>function Export-Credential($cred, $path) { $cred = $cred | Select-Object * $cred.password = $cred.Password | ConvertFrom-SecureString $obj = New-Object psobject $obj | Add-Member -MemberType NoteProperty -Name UserName -Value $cred.username $obj | Add-Member -MemberType NoteProperty -Name Password -Value $cred.password $obj | Export-Clixml $path } function Import-Credential($path) { $obj = Import-Clixml $path $obj.password = $obj.Password | ConvertTo-SecureString return New-Object system.Management.Automation.PSCredential( $obj.username, $obj.password) } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload