PowerBI New-PowerBIReport Powershell cmdlet error "A task was canceled." - powershell

I am trying to create a new PowerBI Report using Powershell .
I am running below command :
$destinationReport = New-PowerBIReport -Path $sourcePBIX -Name $datasetName -WorkspaceId $GroupID -ConflictAction CreateOrOverwrite
It runs the command for a while and through error:
New-PowerBIReport : A task was canceled."
+ ... ionReport = New-PowerBIReport -Path $sourcePBIX -Name $datasetName - ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (Microsoft.Power...ewPowerBIReport:NewPowerBIReport) [New-PowerBIReport], TaskCanceledException
+ FullyQualifiedErrorId : A task was canceled.,Microsoft.PowerBI.Commands.Reports.NewPowerBIReport
The PBIX I am using is of size 200MB so I thought it could be due to time out and I increased the IdleTimeout using the steps in this article How to set Timeout in Powershell .
But this did not worked either .

In the azure devops hosted agent, we do not have the MicrosoftPowerBIMgmt.Reports package. So we recommend you can add the ps commend:
Install-Module -Name MicrosoftPowerBIMgmt.Reports -RequiredVersion 1.0.946
Also, you can try to run the commend line on your local machine and if it works well, please install a self-agent in your local machine to try again.

Related

Issues with Registering PSRepository and Installing VMWare PowerCLI Module

My Setup: Windows 10.17134, PowerShell 5.1.17134.407
When trying to Register a new PSRepository using the Code below….
Register-PSRepository -Name "PSGallery" –SourceLocation "https://www.powershellgallery.com/api/v2/" -InstallationPolicy Trusted
….it gives me the following error:
FullyQualifiedErrorId : UseDefaultParameterSetOnRegisterPSRepository,Register-PSRepository
I am not able to install the VMWare PowerCLI Module with this command:
Save-module -Name vmware.powercli -path c:\temp
….it gives me this error:
FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.SavePackage
Here are the results of a days googling
I'm running
Register-PSRepository
-Name "PSGallery"
–SourceLocation "https://www.powershellgallery.com/api/v2/"
-InstallationPolicy Trusted
(multiline for clarity)
and I kept getting
Register-PSRepository : Use 'Register-PSRepository -Default' to
register the PSGallery repository. At line:1 char:1
+ Register-PSRepository -Name "PSGallery" –SourceLocation "https://www. ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (PSGallery:String) [Register-PSRepository], ArgumentException
+ FullyQualifiedErrorId : UseDefaultParameterSetOnRegisterPSRepository,Register-PSRepository
I assumed this was to do with proxy settings so I tried all of the various methods of setting the proxy in powershell to no avail.
Finally I ran
Get-PSRepository
and discovered that the repository was already registered, it was just untrusted
So I ran
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
The original reason I had for doIng this is because when I run
Install-PackageProvider -Name NuGet -Force -Scope CurrentUser
I get
Install-PackageProvider : No match was found for the specified search
criteria for the provider 'NuGet'. The package provider requires
'PackageManagement' and 'Provider' tags. Please check if the specified
package has the tags. At line:1 char:1
+ Install-PackageProvider -Name NuGet -Force -Scope CurrentUser
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (Microsoft.PowerShel\u2026tallPackageProvider:InstallPackageProvider)
[Install-PackageProvider], Exception
+ FullyQualifiedErrorId : NoMatchFoundForProvider,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackageProvider
Unfortunately, making the repository trusted did no help with my issue
... and the original reason for doing this was so I could run
Install-Module -Name SqlServer -Force -Verbose -Scope CurrentUser
Which was failing (sorry no error message, it was so long ago)
After all my fiddling however, this statement now works without error.
Not sure if it was all the proxy config, or making NuGet trusted or both
I've been chasing this problem for days. I isolated it to Install-PackageProvider not being able to download:
Microsoft.PackageManagement.NuGetProvider-2.8.5.208.dll
In my case, my company does not allow us to download DLLs from the internet without due process. I engaged due process and got an approved copy of the DLL. Then it needs to be placed here:
$env:ProgramFiles\PackageManagement\ProviderAssemblies\nuget\2.8.5.208\Microsoft.PackageManagement.NuGetProvider.dll
Note the version becomes a folder and is stripped from the name.
Manually doing so eliminates the need to run Install-PackageProvider. Some articles state that Import-PackageProvider is necessary to get PowerShell to recognise it. But, I did not need to do the Import. Just try Install-Module -Name SqlServer -Force again.

error when trying to install chocolatey via powershell : cannot connect to remote server

I am trying to install chocolatey by following official documentation (https://chocolatey.org/install), this is what I am doing :
1-I am opening a cmd.exe running as administrator
2-I am running the following command : powershell and then switch into powershell mode
3-I am running the following command : $PSVersionTable.PSVersion and then get the following result : major:5 minor:1 build:16299 revision:785
4-I am running the following command : Get-ExecutionPolicy and then get the following result : RemoteSigned
5-I am running the following command : Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('http
s://chocolatey.org/install.ps1')) and get the following error :
Exception calling "DownloadString" with "1" argument(s): "Unable to connect to the remote server"
At line:1 char:51
+ ... ess -Force; iex ((New-Object System.Net.WebClient).DownloadString('ht ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : WebException
I am working in a company (our os is windows 10 enterprise), and when trying or any colleague machine it's working perfectly and there is no (from what we have seen) any configuration difference between them and me.
Thanks in advance
There is nothing wrong with the code you tried. Basically, it is telling you that you are unable to connect, which might be a restriction or policy. Try the following:
$req = [System.Net.HttpWebRequest]::Create("https://www.google.com")
$req.Proxy = [System.Net.WebRequest]::DefaultWebProxy
$req.Proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials
Then run the comment again. It has something to do with the credentials used in windows 10 for the request.

Not able to run PowerShell on Jenkins

I am running a PowerShell script which will stop a service on remote machine. When I am running it in PowerShell ISE then it is running fine. But when I am trying to run it from Jenkins hosted on my local machine it is giving me an error.
$SQL_agent="SQLSERVERAGENT"
$SQL_server="MSSQLSERVER"
$SQL_Agent_Service = Get-Service -Name $SQL_agent -ComputerName 192.168.48.44
$SQL_Server_Service = Get-Service -Name $SQL_server -ComputerName 192.168.48.44
Stop-Service -InputObject $SQL_Agent_Service
log("[SQLSERVERAGENT] shutdown complete.");
Stop-Service -InputObject $SQL_Server_Service
log("[MSSQLSERVER] shutdown complete.");
I am getting following error while running it from jenkins (jenkins is running on my local machine),
<pre>
D:\Eclipse_Repository\self_repo\jmallick\remote_db_backup.ps1:42 char:22
+ ... ent_Service = Get-Service -Name $SQL_agent -ComputerName 192.168.48.44
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (SQLSERVERAGENT:String) [Get-Ser
vice], ServiceCommandException
+ FullyQualifiedErrorId : NoServiceFoundForGivenName,Microsoft.PowerShell.
Commands.GetServiceCommand
Get-Service : Cannot find any service with service name 'MSSQLSERVER'.At
D:\Eclipse_Repository\self_repo\jmallick\remote_db_backup.ps1:43 char:23
+ ... er_Service = Get-Service -Name $SQL_server -ComputerName 192.168.48.44
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (MSSQLSERVER:String) [Get-Servic
e], ServiceCommandException
+ FullyQualifiedErrorId : NoServiceFoundForGivenName,Microsoft.PowerShell.
Commands.GetServiceCommand
</pre>
Any thoughts on this?
It looks like Jenkins is not running under the same account as of MSSQLSERVER
To change account for jenkins or MSSQLSERVER service
Follow go to services
right click on Jenkins services and select Properties.
Go to Log On tab
Click on This Account
In browse dialog select the user account you want o run Jenkins or Database server in

PowerShell remote restart service running from a TFS build error

I have a TFS build definition contains a PowerShell Script build step. I would like to run the following command on a remote computer(DEVWS45PC) which should restart the service named StartSeleniumGridHub:
winrm s winrm/config/client '#{TrustedHosts="DEVWS45PC"}'
Restart-Service -InputObject $(Get-Service -Computer DEVWS45PC -Name StartSeleniumGridHub)
This gives me this error:
##[error]Get-Service : Cannot find any service with service name 'StartSeleniumGridHub'.
At E:\builds_2017\killBrowsersOnAllNodesAndRestartHub.ps1:43
char:36
+ Restart-Service -InputObject $(Get-Service -Computer DEVWS45PC -Name StartSe ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (StartSeleniumGridHub:String) [Get-Service], ServiceCommandException
+ FullyQualifiedErrorId : NoServiceFoundForGivenName,Microsoft.PowerShell.Commands.GetServiceCommand
Restart-Service : Cannot validate argument on parameter 'InputObject'. The argument is null or empty. Provide an
argument that is not null or empty, and then try the command again.
At E:\builds_2017\killBrowsersOnAllNodesAndRestartHub.ps1:43
char:34
+ Restart-Service -InputObject $(Get-Service -Computer DEVWS45PC -Name StartSe ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Restart-Service], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.RestartServiceCommand
I can run this script without any problem from any of my computers. Note that 'DEVWS45PC' is truly set as a trusted host on the TFS build agent computer, so it's not the problem.
I have no clue what is the problem. Maybe authentication problems?
You could manually RDP to the remote machine DEVWS45PC with your build service account and run the powershell script.
Most likely lacking of permissions of your build service account(Due to could not find the service). Suggest you add the service account to your local Administrator group on the remote machine DEVWS45PC and try again.
Also make sure you are using the PowerShell on Target Machines task instead of powershell task in the build definition.

Powershell DSC xChrome Sample failing on AzureVM

I'm attempting to run the xChrome sample (https://gallery.technet.microsoft.com/scriptcenter/DSC-Resource-Kit-All-c449312d) on an Azure VM and it fails to run. Everything runs and executes, but I receive the error (larger log snippet below):
CategoryInfo : ObjectNotFound: (MSFT_xChrome\MSFT_xChrome:String) [Configuration]
AzureVM is Windows Server 2012 with Powershell Version 5:
$PSVersionTable.PSVersion
Major Minor Build Revision
5 0 9883 0
The steps I use to execute are:
Download xChrome extension (from above url) and inflate it into my modules directory
Publish-AzureVMDscConfiguration -ConfigurationPath
C:\Users\Documents\WindowsPowerShell\Modules\xChrome\Example\Sample_xChrome.ps1
-Force
Get-AzureVM -ServiceName '' -Name '' |
Set-AzureVMDscExtension -ConfigurationArchive Sample_xChrome.ps1.zip
-ConfigurationName Sample_InstallChromeBrowser -ConfigurationArgument #{Language='en';LocalPath='$env:SystemDrive\Windows\DtlDownloads\GoogleChromeStandaloneEnterprise.msi'} | Update-AzureVM
**The error snippet:*
[2015-04-17T23:35:06] Executing the configuration function to generate the MOF files.
PSDesiredStateConfiguration\Configuration : The module 'MSFT_xChrome' could not be loaded. For more information, run 'Import-Module MSFT_xChrome'.
At C:\Packages\Plugins\Microsoft.Powershell.DSC\1.7.0.0\DSCWork\Sample_xChrome.ps1.8\Sample_xChrome.ps1:3 char:1
Configuration Sample_InstallChromeBrowser
~~~~~~~~~~~~~
CategoryInfo : ObjectNotFound: (MSFT_xChrome\MSFT_xChrome:String) [Configuration], ParentContainsErrorRecordException
FullyQualifiedErrorId : CouldNotAutoLoadModule,Configuration
[2015-04-17T23:35:08] Removing file lock
C:\Packages\Plugins\Microsoft.Powershell.DSC\1.7.0.0\bin\DscExtensionHandler.ps1 : Error enabling the DSC Extension: Errors occurred while processing configuration 'Sample_InstallChromeBrowser'.
At line:7 char:2
+ C:\Packages\Plugins\Microsoft.Powershell.DSC\1.7.0.0\bin\DscExtensio ...
I fixed this error by changing how I was importing the module.
Import-DscResource -ModuleName xChrome -Name MSFT_xChrome
The error implies that a module could not be loaded. Can you connect to the VM using remote desktop and check if Get-DscResource -Module xChrome lists the resource correctly