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

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.

Related

Activate a virtual environment in Windows Powershell with a command that is equivalent to "source"

I need to activate a virtual environment in Windows Powershell. But, the guide i am using that to proceed my project tells me to use a command like this:
source venv-slither/bin/activate
In my project directory, in first, i installed virtualenv with:
pip3 install virtualenv
After that, I setup a virtual environment in folder ./venv-slither with:
source venv-slither/bin/activate
Problem emerges here. Whenever i run the last command i approaches to this message in Powershell:
source : The term 'source' 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:2
+ source venv-slither/bin/activate
+ ~~~~~~
+ CategoryInfo : ObjectNotFound: (source:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
I read some guide to eliminate this. They suggest using . instead source, but by this way the same error occurs. When, my Command is:
. venv-slither/bin/activate
The message is:
. : The term 'venv-slither/bin/activate' 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:3
+ . venv-slither/bin/activate
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (venv-slither/bin/activate:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
More over, when i change slashes direct:
. venv-slither\bin\activate
This message comes up:
. : The module 'venv-slither' could not be loaded. For more information, run 'Import-Module venv-slither'.
At line:1 char:3
+ . venv-slither\bin\activate
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (venv-slither\bin\activate:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CouldNotAutoLoadModule
I have these modules in my project directory: .bin, dot, findit, source.
Please help a beginner man in working with Windows Powershell.
I think you should use like this, within Windows PS:
venv-slither/Scripts/activate.ps1
After enabling the necessary execution policy for the current user with this command:
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser
I would return to previous policy with this command, after you finish your work, for safety:
Set-ExecutionPolicy -ExecutionPolicy Undefined -Scope CurrentUser
There are other ways to set the execution temporarily. For example, I can set for the current PS's session by issuing this command:
powershell.exe -ExecutionPolicy RemoteSigned
* RemoteSigned or Unrestricted, you can refer to this link to view the details which scripts are or not allowed for each type of policy:
https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7.1
Sorry for posting too late, I've just run into your post when found the same issue, tested myself and it worked.

Get-PSRepository commands giving two outputs with two Powershell ISE

When i run Get-PSRepository using Powershell ISE(x86) it shows me the source location and installation policy as trusted. The source location it shows is https://www.powershellgallery.com/api/v2
But when i run the same command using Powershell ISE without the x86 from my machine i get the below error:
Get-PSRepository : The 'Get-PSRepository' command was found in the module 'PowerShellGet', but the module
could not be loaded. For more information, run 'Import-Module PowerShellGet'.
At line:1 char:1
+ Get-PSRepository
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-PSRepository:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CouldNotAutoloadMatchingModule
Why powershell is displaying the two behaviours with two different ISE is it because of environment variable or what?

Running Invoke-AzureRmVMRunCommand through Azure automation

I am trying to run a script thorugh Invoke-AzureRmVMRunCommand from azure automation but it is showing cmdlet does not exist. Please let me know how to implement this.
Below the script
Invoke-AzureRMVMRunCommand -ResourceGroup 'XXXXXX' -Name XXXXX-CommandID 'RunPowerShellScript' -ScriptPath 'Test.ps1'
Error details.
Invoke-AzureRMVMRunCommand : The term 'Invoke-AzureRMVMRunCommand' 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:1
+ Invoke-AzureRMVMRunCommand -ResourceGroup 'olf3em-rds-mgmt' -Name OLF ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Invoke-AzureRMVMRunCommand:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
You need to install modules before using those:
https://learn.microsoft.com/en-us/azure/automation/automation-runbook-gallery#modules-in-powershell-gallery
in short:
go to modules
browse gallery
install
The Invoke-AzureRmVMRunCommand command is included in the AzureRM.Compute module. Which you will first need to install in your Automation Account.

How to deploy a Powershell module in company?

I have my own Powershell module which I use on many servers. I keep it on a network share which is added on some machines to the PSModulePath variable: \\\Server\Scripts\MyModule\.
This allowed me to always use the latest version of my module on each server and I only had to update a single copy.
Now with Powershell 5 there is an issue. If I have this network path in PSModulePath I can't remote onto this machine.
Enter-PSSession : The term 'Measure-Object' is not recognized as the name of a cmdlet, function, script file, or operab
le 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:1
+ Enter-PSSession Server
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Measure-Object:String) [Enter-PSSession], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
It's a known error and it could be fixed with enabling second hoop.
Is there a better way to deploy a module and keep it always up-to-date then my approach?

Powershell Runbook - The term 'Get-AzureRMWebAppSlot' is not recognized as the name of a cmdlet

I'm trying to switch connection strings of a website to perform DB Failover, as part of HighAvailability. Please suggest if there are any suitable workarounds for the current requirement.
However, the same script which ran on my local machine is not executing while in the Azure portal as a PowerShell Workflow Runbook.
Powershell Code:
Set-AzureRMWebAppSlot -ResourceGroupName $reourceGroupName -Name $WebSiteName -ConnectionStrings $SecnodaryConnectionStrings -Slot $WebSiteSlot
Error:
Set-AzureRMWebAppSlot : The term 'Set-AzureRMWebAppSlot' 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 AppService-DBConnnectionFailoverSwitch:37 char:37
+
+ CategoryInfo : ObjectNotFound: (Set-AzureRMWebAppSlot:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
This can be done by adding modules to your automation account under Assets
Assets > Modules > Add a Module
Browse Gallery to find AzureRM.Compute