You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I run Azure DevOps pipeline. I get the below error
Import-Module -Name C:\Modules\az_9.3.0\Az.Accounts\2.11.1\Az.Accounts.psd1 -Global
##[warning]Both Az and AzureRM modules were detected on this machine. Az and AzureRM modules cannot be imported in the same session or used in the same script or runbook. If you are running PowerShell in an environment you control you can use the 'Uninstall-AzureRm' cmdlet to remove all AzureRm modules from your machine. If you are running in Azure Automation, take care that none of your runbooks import both Az and AzureRM modules. More information can be found here: https://aka.ms/azps-migration-guide
Clear-AzContext -Scope CurrentUser -Force -ErrorAction SilentlyContinue
Clear-AzContext -Scope Process
Connect-AzAccount -ServicePrincipal -Tenant xxxxxxxxxxxxxxxx-Credential System.Management.Automation.PSCredential -Environment AzureCloud @processScope
Az module initialization Complete
Beginning Script Execution
& 'D:\a_temp\xxxxxxxxxxxxxxxxxxxxx.ps1'
Name Account SubscriptionName Environment TenantId
App name xxxxxxx.. xxxxxx. AzureCloud xxxxxxx.
Disconnect-AzAccount -Scope Process -ErrorAction Stop
Clear-AzContext -Scope Process -ErrorAction Stop
##[error]Invalid JSON primitive: .
Finishing: Configure Virtual Machine - client
Below is my code
[CmdletBinding()]
param (
[Parameter(Mandatory)]
[string]
$DomainJoin,
When I run Azure DevOps pipeline. I get the below error
Import-Module -Name C:\Modules\az_9.3.0\Az.Accounts\2.11.1\Az.Accounts.psd1 -Global
##[warning]Both Az and AzureRM modules were detected on this machine. Az and AzureRM modules cannot be imported in the same session or used in the same script or runbook. If you are running PowerShell in an environment you control you can use the 'Uninstall-AzureRm' cmdlet to remove all AzureRm modules from your machine. If you are running in Azure Automation, take care that none of your runbooks import both Az and AzureRM modules. More information can be found here: https://aka.ms/azps-migration-guide
Clear-AzContext -Scope CurrentUser -Force -ErrorAction SilentlyContinue
Clear-AzContext -Scope Process
Connect-AzAccount -ServicePrincipal -Tenant xxxxxxxxxxxxxxxx-Credential System.Management.Automation.PSCredential -Environment AzureCloud @processScope
Az module initialization Complete
Beginning Script Execution
& 'D:\a_temp\xxxxxxxxxxxxxxxxxxxxx.ps1'
Name Account SubscriptionName Environment TenantId
App name xxxxxxx.. xxxxxx. AzureCloud xxxxxxx.
Disconnect-AzAccount -Scope Process -ErrorAction Stop
Clear-AzContext -Scope Process -ErrorAction Stop
##[error]Invalid JSON primitive: .
Finishing: Configure Virtual Machine - client
Below is my code
[CmdletBinding()]
param (
[Parameter(Mandatory)]
[string]
$DomainJoin,
)
$ErrorActionPreference = 'SilentlyContinue'
$report = ""
Add to Domain
$Domain = Get-WmiObject win32_computersystem
if (($Domain).partofdomain -eq $true) {
$report += "Already added to Domain: $ (($Domain).Domain); "
}
else {
$password = $DomainJoin | ConvertTo-SecureString -asPlainText -Force
$username = "[email protected]"
$credential = New-Object System.Management.Automation.PSCredential($username, $password)
}
Disable Local Firewall
'Domain', 'Private', 'Public' | ForEach-Object { Set-NetFirewallProfile -Profile $_ Enabled False }
Local Admins Users and Groups
Groups
if ($Groups.Length -gt 0) {
$adminGroups = $Groups.Split(",")
foreach ($group in $adminGroups) {
Add-LocalGroupMember -Group "Administrators" -Member $group -ErrorAction SilentlyContinue
}
}
Users
if ($Users.Length -gt 0) {
$adminUsers = $Users.Split(",")
foreach ($user in $adminUsers) {
Add-LocalGroupMember -Group "Administrators" -Member $user -ErrorAction SilentlyContinue
}
}
Write-Output $report
#Exit
exit 0
The text was updated successfully, but these errors were encountered: