"Could not find a part of the path" creating a service - powershell

I tried to create Azure cloud service using:
Create the Cloud Service
New-AzureServiceProject -ServiceName 'service-lift-and-shift' -Verbose
I am using Azure SDK 2.9 and it is giving the following error:
ServiceName: service-lift-and-shift
New-AzureServiceProject : Could not find a part of the path 'C:\Program Files (x86)\Microsoft
SDKs\Azure\PowerShell\ResourceManager\AzureResourceManager\AzureRM.Profile\Resources\Scaffolding\General\scaffold.xml'.
At line:1 char:1
+ New-AzureServiceProject
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [New-AzureServiceProject], DirectoryNotFoundException
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.CloudService.Development.Scaffolding.NewAzureServiceProjectCommand

I solved this problem by copying folder
C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ServiceManagement\Azure\Services\Resources
to
C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ResourceManager\AzureResourceManager\AzureRM.Profile

Since you want create a Could Service which only exists in ASM mode, you should logged in with command: Add-AzureAccount.
I logged in with Add-AzureRmAccount in the first time and I got the same error as you. But when I logged in with Add-AzureAccount in ASM mode, it works.
So make sure you were logged in ASM mode.

Related

Powershell invoking DTUTIL error

I'm currently in the process of building a deployment process in octopus deploy and as part of that I want to use DTUTIL to create folders and load SSIS packages to our server.
This text "C:\Program Files (x86)\Microsoft SQL Server\130\DTS\Binn\dtutil.exe" /SourceServer [servername] /FC SQL;\;[foldername], with appropriate server and folder names, which works in DOS.
Here is the rub, if I use the same code in Powershell I get an error:
$Command ="`"C:\Program Files (x86)\Microsoft SQL Server\130\DTS\Binn\dtutil.exe`" /SourceServer MYSERVER /FC SQL;\;Folder1";
invoke-Expression $Command;
invoke-expression : At line:1 char:73
+ ... Files (x86)\Microsoft SQL Server\130\DTS\Binn\dtutil.exe" /SourceSe ...
+ ~
You must provide a value expression following the '/' operator.
At line:1 char:73
+ ... \Microsoft SQL Server\130\DTS\Binn\dtutil.exe" /SourceServer MYSERVER ...
+ ~~~~~~~~~~~~
Unexpected token 'SourceServer' in expression or statement.
At line:1 char:1
+ invoke-expression $Command
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ParserError: (:) [Invoke-Expression], ParseException
+ FullyQualifiedErrorId : ExpectedValueExpression,Microsoft.PowerShell.Commands.InvokeExpressionCommand
Has anyone got any idea how to remedy this?
Anthony
You can execute the EXE using the & operator:
& "C:\Program Files (x86)\Microsoft SQL Server\130\DTS\Binn\dtutil.exe" /SourceServer MYSERVER /FC SQL;\;Folder1
Also, the above Invoke-Expression command failed in the same way when I ran it in PowerShell directly, this doesn't appear to be an issue with running the PowerShell within Octopus.

'Set-AzureRmDataFactoryV2' is not recognized as the name of a cmdlet

I have installed Powershell 6.0.0 on Ubuntu 16.04. I am getting following error when trying to create Azure Data Factory using Powershell
Set-AzureRmDataFactoryV2 : The term 'Set-AzureRmDataFactoryV2' 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 line:1 char:16
+ $DataFactory = Set-AzureRmDataFactoryV2 -ResourceGroupName $ResGrp.Re ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Set-AzureRmDataFactoryV2:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Then I tried to install the module and getting the following error
Install-Module AzureRM -AllowClobber
Untrusted repository You are installing the modules from an untrusted repository. If you trust this repository, change its InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from 'PSGallery'?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): Y
PackageManagement\Install-Package : The member 'TypesToProcess' in the module manifest is not valid: Cannot find path '/tmp/787167149/Azure.Storage/.\Microsoft.WindowsAzure.Commands.Storage.Types.ps1xml' because it does not exist.. Verify that a valid value is specified for this field in the '/tmp/787167149/Azure.Storage/Azure.Storage.psd1' file. At /opt/microsoft/powershell/6.0.0/Modules/PowerShellGet/1.6.0/PSModule.psm1:2057 char:21 + ... $null = PackageManagement\Install-Package #PSBoundParameters + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ResourceUnavailable: (/tmp/787167149/...re.Storage.psd1:String) [Install-Package], Exception + FullyQualifiedErrorId : Modules_InvalidManifest,Microsoft.PowerShell.Commands.TestModuleManifestCommand,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage
Currently, Set-AzureRmDataFactoryV2 cmdlet is not supported on Linux. AzureRM.NetCore supports following services.
Virtual Machine
App Service (Websites)
SQL Database
Storage
Network
More information please refer to this official document.
If possible, I suggest you could use Azure CLI.
I have solved this issue in my machine by updating Az.DataFactory module.
Install/update latest AzureRM.DataFactoryV2 module.
Restart your powershell.
try the above command.
it will work successfully.

Neo4j with Windows Powershell : xxxx is not a Neo4j Home directory

I've installed Neo4j (exe installer) and I've also extracted the powershell module from the zip file but now when I try to do anything I just get an error message like:
PS C:\dev\github\neo4j-sandbox\src\ps> Get-Neo4jServer c:\dev\github\neo4j-sandbox\neo4jdb
Get-Neo4jServer : c:\dev\github\neo4j-sandbox\neo4jdb is not a Neo4j Home directory
At line:1 char:1
+ Get-Neo4jServer c:\dev\github\neo4j-sandbox\neo4jdb
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Get-Neo4jServer
At first I thought perhaps I was misinterpreting what the neo4j "home directory" was and tried pointing it to the installation directory, but I just get the same error message.
PS C:\dev\github\neo4j-sandbox\src\ps> Get-Neo4jServer "c:\Program Files\Neo4j CE 2.3.2"
Get-Neo4jServer : c:\Program Files\Neo4j CE 2.3.2 is not a Neo4j Home directory
At line:1 char:1
+ Get-Neo4jServer "c:\Program Files\Neo4j CE 2.3.2"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Get-Neo4jServer
So, what is the "Neo4j Home Directory" - I couldn't find a definition for that anywhere. Is it the data directory, or the installation directory, or something completely different.
It seems that somehow or another the installation via the exe download is different from the installation in the zip. I would have expected them to be the same, with the exe version just being automated.
Anyway, if you extract the zip file and copy the contents of the neo4j-community-2.3.2 (or appropriate for your version/edition) folder inside the zip file into a folder on your hard-drive, then point the PowerShell script at that folder it is happy to report the version of the installation.

Cannot Copy a file from a network share in powershell until I open the share in windows explorer

I have a very simple powershell script which to copy files from a networked server.
here's the script
Write-Output "Copying Backups"
copy \\sqlbox\SqlBackups\Client.bak c:\sqlbackups
It throws this exception
Invalid Path: '\\sqlbox\SqlBackups\Client.bak'.
At C:\Work\db\restore.ps1:5 char:1
+ copy \\sqlbox\SqlBackups\Client.bak c:\sqlbackups
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], ArgumentException
+ FullyQualifiedErrorId : CopyItemDynamicParametersProviderException
If I open a windows explorer up and goto \sqlbox\SqlBackups it opens fine and if I then run the powershel script it also starts working and will work until the next time I reboot the PC.
How can I address this in the script?
Try mapping the drive first, then carry out the copy operation.
New-PSDrive -Name S -Root \\sqlbox\SqlBackups\ -PSProvider FileSystem
Write-Output "Copying Backups"
copy S:\Client.bak c:\sqlbackups
I have a similar problem when copying files over servers with this error:
Cannot find path '\\computer1\d$\path' because it does not exist.
It works after adding Microsoft.PowerShell.Core\FileSystem:: in front of file name:
copy-item "Microsoft.PowerShell.Core\FileSystem::\\computer1\d$\path\installer.msi" "Microsoft.PowerShell.Core\FileSystem::\\computer2\d$\path\installer.msi"

Windows Azure PowerShell cmdlet Error - File skipped because it was already present

Running the following Windows Azure PowerShell cmdlet for Windows Azure: Import-Module 'C:\Program Files (x86)\Microsoft SDKs\Windows Azure\PowerShell\Azure\Azure.psd1' generates the error below. I ran PowerShell with elevated priveleges and Get-ExecutionPolicy returns RemoteSigned.
Here is the error:
Import-Module : The following error occurred while loading the extended type data file:
Microsoft.PowerShell, C:\Program Files (x86)\Microsoft SDKs\Windows Azure\PowerShell\Azure\Microsoft.WindowsAzure.Manag
ement.Websites.Types.ps1xml : File skipped because it was already present from "Microsoft.PowerShell".
Microsoft.PowerShell, C:\Program Files (x86)\Microsoft SDKs\Windows Azure\PowerShell\Azure\Microsoft.WindowsAzure.Manag
ement.SqlDatabase.Types.ps1xml : File skipped because it was already present from "Microsoft.PowerShell".
At line:1 char:14
+ Import-Module <<<< 'C:\Program Files (x86)\Microsoft SDKs\Windows Azure\PowerShell\Azure\Azure.psd1'
+ CategoryInfo : InvalidOperation: (:) [Import-Module], RuntimeException
+ FullyQualifiedErrorId : FormatXmlUpateException,Microsoft.PowerShell.Commands.ImportModuleCommand
The script does not complete after this error.
After half a day of being stuck on this, I just decided to continue with the steps, and it worked flawlessly. So I guess it was simply a warning, but did not effect the rest of the process. I have not had any issues as a result.