How to import splitpipeline module from a shared server? - powershell

My script uses the Powershell splitpipeline module, to bring parallel process and queues features.
The script and the module are stored on shared server, like \server\c$ , the idea is be able to run it from any computer.
Tried to put at begining of the script import-module \\server\c$\SplitPipeline but I recieve the error:
import-module : Could not load file or assembly 'file://\\server\c$\SplitPipeline\SplitPipeline.dll' or one of its dependencies.
Operation is not supported. (Exception from HRESULT: 0x80131515)
At D:\scripts\powershell\OstReport_BETA-PIPE.ps1:6 char:1
+ import-module \\server\c$\SplitPipeline
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Import-Module], FileLoadException
+ FullyQualifiedErrorId : FormatXmlUpdateException,Microsoft.PowerShell.Commands.ImportModuleCommand
If I try to copy it from the srv to the pc with:
Copy-Item -Path \\server\c$\SplitPipeline -Destination C:\windows\system32\WindowsPowerShell\v1.0\Modules -recurse -force
I get a access denied
any ideas¿?
thanks

The issue you're experiencing is that .NET assemblies can't be loaded from an untrusted UNC path, without special configuration. As you already discovered, the simplest solution is to copy the module to your local computer first.
To work around the "Access Denied" message, copy the module to your user directory, not the system-wide directory.
c:\users\<username>\Documents\WindowsPowerShell\Modules
You need to run PowerShell "as Administrator" in order to have permission to copy to the system folder, however it is generally recommended not to modify the default system directory. Instead, copy the module to your user folder (as above).

Related

Copy file between remote file systems using windows PowerShell

I am on a corporate VPN. I have access to two remote file shares which have windows mapped paths. I can view both file shares in Windows Explorer. My goal is to copy a 1.8 gb .csv file from one share, to the other. I can copy much smaller files with no problem, simply using windows explorer. However, for files around 300mb or greater, I get an error copying the file. The file appears in the destination file share as the correct size, but reading it into python confirms that not all the csv rows are copied.
I am now attempting to copy the file using Windows 10 PowerShell, to open the door to more control over the copy operation, rather than the GUI copy command executed through the Windows 10 desktop environment. (I am replacing the true path names, with stand-ins for privacy)
When I run: Copy-Item \\sourcePath\aFile.csv \\destinationPath\aFile.csv -Verbose -Force
I get the error
Copy-Item : An unexpected network error occurred.
At line:1 char:1
+ Copy-Item '\\sourcePath\ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Copy-Item], IOException
+ FullyQualifiedErrorId : System.IO.IOException,Microsoft.PowerShell.Commands.CopyItemCommand
I am hoping that in powershell there is some way to either make the copy operation more robust to VPN bandwidth/connection stability limitations, or to cut my client computer out of the copy operation, and order the source file share to directly copy the file to the destination machine, without my machine serving as a middle man relay between the two. It is clear from my network traffic that my machine is downloading and then uploading the file while the failing copy operation runs.
Are you looking to replace the same item that's in the remote path?
Copy-Item -path \\sourcePath\aFile.csv -destination \\destinationPath\aFile.csv\ -Verbose -Force
It could very well be creds aren't being passed since youre on a VPN which you would have to double hop.
A solution is to use robocopy to copy the file.
robocopy “\\aSourcePath\\” “\\aDestinationPath\\” “aFileInSourcePath.something” /mt /z
runs until the file is transfered, is robust to VPN disruptions that seem to cause standard Windows Explorer copy/paste to fail.

Powershell AzureML Get-AmlWorkspace

Get-AmlWorkspace : One or more errors occurred.
At line:1 char:1
+ Get-AmlWorkspace
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-AmlWorkspace],
AggregateException
+ FullyQualifiedErrorId :
System.AggregateException,AzureML.PowerShell.GetWorkspace
I am trying to use Powershell to connect to Azure ML studio as it looks like an easier way to manage a workspace. I've downloaded the dll file from https://github.com/hning86/azuremlps and changed my config.json file, but get the error above if I try to run any AzureML commands. I've unblocked the DLL file and imported the AzureMLPS module, and I can see the module and commands I am trying to use have been imported by doing Get-Module and Get-Command
For info I've not used Powershell before.
Any suggestions much appreciated!
Have you installed Azure PowerShell Installer on your local machine?
Click here for more info.
Download the latest Azure PowerShell Installer (4.3.1), then install on your local machine. Then retry using Azure PowerShell module and commands.
I installed mine last May, using Azure PowerShell 4.0.1, and the command Get-AmlWorkspace is working.
# Set local folder location
Set-Location -Path "C:\Insert here the location of AzureMLPS.dll"
# Unblock and import Azure Powershell Module (leverages config.json file)
Unblock-File .\AzureMLPS.dll
Import-Module .\AzureMLPS.dll
# Get Azure ML Workspace info
Get-AmlWorkspace
The output on my side looks like this:

Powershell PSModule unc path

I am adding a UNC path, like "\\server\share\modules" to the user session env variable PSModule like this:
$env:PSModulePath = $env:PSModulePath + ";\\server\share\modules"
But, when I try to load a module from this path, I get an error
PS C:\> Import-Module WS_XML_MODULE
Import-Module : The specified module 'WS_XML_MODULE' was not loaded because no valid module file was found in any module directory.
At line:1 char:1
+ Import-Module WS_XML_MODULE
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (WS_XML_MODULE:String) [Import-Module], FileNotFoundException
+ FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
Listing all the available modules, which should show the UNC path available modules, doesn't show me any of the UNC folder modules...
Get-Module -listavailable
Anybody knows why?
Thanks
Go this working...
I took a look at the system modules folder and the syntax of the folders and files are exacly the same, with dots separating words like Microsoft.Powershell.Something
I then changed the name of the PSM1 file to the same and got them into folder with the same name and BAmm.. in a heartbeat loaded all my modules.
Place the "WS_XML_MODULE.psm1 and WS_XML_MODULE.psd1" in the folder named "WS_XML_MODULE".
Make sure "WS_XML_MODULE" folder is located in "\\server\share\modules"
Note: Don't include the Module name in Path

Add-appxPackage deployment failed: does not find files

I am trying to deploy windows 10 app that I created to a laptop. In my computer everything goes fine, but in the laptop the Add-appPackage first recognizes the relevant package files, but when running the line in the script that makes the unbundle it fails and returns with:
' The system cannot find the file specified' eventhough the files exists.
I tried to make a deploy using the -register flag from working solution directory but the result was the same.
I use in my computer Windows 10 HOME and the Laptop is Windows 10 Pro but I think it does not matter.
The line in the script file generated by the visual studio packager which fails is:
Add-AppxPackage -Path $DeveloperPackagePath.FullName -DependencyPath $DependencyPackages.FullName -ForceApplicationShutdown
I checked the variables - they contain correct data.
Afterwards it outputs the error with the line:
$Error[0] # Dump details about the last error
that does not give me too much details about which file is missing as you can see in the full output:
C:\users\User\AlephBet_1.0.4.0_Test\Dependencies\x86\Microsoft.NET.Native.Framework.1.3.appx
C:\users\User\AlephBet_1.0.4.0_Test\Dependencies\x86\Microsoft.NET.Native.Runtime.1.3.appx
C:\users\User\AlephBet_1.0.4.0_Test\Dependencies\x86\Microsoft.VCLibs.x86.14.00.appx
C:\users\User\AlephBet_1.0.4.0_Test\Dependencies\x64\Microsoft.NET.Native.Framework.1.3.appx
C:\users\User\AlephBet_1.0.4.0_Test\Dependencies\x64\Microsoft.NET.Native.Runtime.1.3.appx
C:\users\User\AlephBet_1.0.4.0_Test\Dependencies\x64\Microsoft.VCLibs.x64.14.00.appx
Add-AppxPackage : The system cannot find the file specified.
The system cannot find the file specified.
At C:\users\User\AlephBet_1.0.4.0_Test\Add-AppDevPackage.ps1:388 char:13
+ Add-AppxPackage -Path $DeveloperPackagePath.FullName -Dep ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Add-AppxPackage], FileNotFoundException
+ FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.Windows.Appx.PackageManager.Commands.A ddAppx
PackageCommand
I tried also getting information with get-AppxLog but it does log the error.
What happens? What is missing? Is there a way to get more information about the error?
Where does Windows 10 put the appx? Is there a way to make a bypass and take the files from an existing executable version, something like .exe files and copy them as is to the laptop?

PowerShell Copy-Item gives error in Octopus

I try to copy a DLL file from my computer to another and register it:
net use \\RemoteIp\C$\Dev 'pass'/USER:'user'
copy-item "D:\test.dll" -Destination "\\RemoteIp\c$\Dev";
regsvr32 "\\RemoteIp\C$\Dev\test.dll"
The problem that I have is that when I try to run this script from Octopus I receive this error :
Copy-Item : Cannot find path 'D:\test.dll' because it does
not exist.
At C:\Octopus\Work\20160606100457-74\Script.ps1:3 char:10
+ copy-item <<<< "D:\test.dll" -Destination "\RemoteIp\c$\Dev";
+ CategoryInfo : ObjectNotFound: (D:\test.dll
:String) [Copy-Item], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.CopyI
temCommand
The remote script failed with exit code 1
If I try to run these lines of code in PowerShell it works properly.
Any suggestions ?
Thank you
Actually this was my fault. When you are running a script in Octopus that is meant to run on the Deployment target:
you have to define your local pc with the ip address. For example, in my case I had to write the address "D:\test.dll" like this : "\192.168.00.00\D$\test.dll" .
For the regsvr32 problem, I added a bat file on the server that runs the regsvr32 instruction and I just call that file and it does the rest.
Hopefully that helps others :)