powershell

Connect-AzAccount without prompt

北城余情 提交于 2021-01-28 19:01:45
问题 I am trying to login into Azure Portal by using Connect-AzAccount This code asks me for a prompt which I don't want, can we Auto login by using some simple config script. 回答1: As Joy said, you could login with the user account by credential which will no prompt, make sure your account doesn't enable the MFA. $User = "xxx@xxxx.onmicrosoft.com" $PWord = ConvertTo-SecureString -String "<Password>" -AsPlainText -Force $tenant = "<tenant id>" $subscription = "<subscription id>" $Credential = New

Replace multiple strings in a file using powershell

℡╲_俬逩灬. 提交于 2021-01-28 18:54:56
问题 I am using following coe to replace the string $folders=Get-ChildItem -Path "C:\temp\Database Scripts" foreach($folder in $folders) { Write-Host $folder $spath=[string]::Concat("C:\temp\Database Scripts\", $folder) $subfolders=Get-ChildItem $spath foreach($subfolder in $subfolders ) { if($subfolder -match "Running Scripts") { $subfolerpath=[string]::Concat($spath,"\",$subfolder,"\*") $files =get-childitem -Path $subfolerpath -include "AVEVAScripts*" if($files -ne $null) { foreach( $file in

Using global variables in a ps1

非 Y 不嫁゛ 提交于 2021-01-28 18:43:41
问题 I can't seem to find good enough solution to my problem. Is there a good way of grouping variables in some kind of file so that multiple scripts could access them? I've been doing some work with Desired State Configuration but the work that needs to be done cannot be efficiently implemented that way. The point is to install Azure Build Agent on a server and then to configure it. There are some variables that really should not be inside a script file just copypasted like Personal Access Token.

Powershell access XML node with multiple attributes within a forloop

≯℡__Kan透↙ 提交于 2021-01-28 18:00:54
问题 xml sample <?xml version="1.0" encoding="UTF-8"?> <CUSTOMERS xml:lang="en"> <CUSTOMER CREATED_DATE="2020-10-16 13:21:09.0" GROUP_ID="" ID="1509999"> <NAME> <TITLE></TITLE> <FIRST_NAME>John</FIRST_NAME> <LAST_NAME>Smith</LAST_NAME> </NAME> <GENDER/> <DATE_OF_BIRTH/> <CONTACT_DETAILS> <TELEPHONE MARKETING_OPT_IN="F" TYPE="MOBILE">0123456789</TELEPHONE> <EMAIL MARKETING_OPT_IN="F">test@yahoo.com</EMAIL> </CONTACT_DETAILS> <ATTRIBUTE NAME="theCompany-News and offers on theCompany Womenswear_OPT

Replacing all occurrences of a string in a Word file by an hyperlink

两盒软妹~` 提交于 2021-01-28 16:31:47
问题 I have to create a Powershell script that reads a Word file (.docx) and replaces strings by hyperlinks. So far, based on this script, I can replace all occurrences of a string by another string easily. With that script, I can look for a string and replace it by an hyperlink. However, only the first occurrence is replaced. Here's my understanding of the problem so far : The first script uses the ReplaceWith and Replace=wdReplaceAll parameters of the Execute function of the Find Interface. The

Wildcard and Naked CNAME records in Azure DNS

家住魔仙堡 提交于 2021-01-28 14:07:06
问题 I'm migrating all my DNS services to Azure DNS. Using Powershell I've managed to successfully create the CNAME record to get www.something.com to resolve to an Azure website- $rs = New-AzureRmDnsRecordSet -Name "www" -RecordType "CNAME" -ZoneName "something.com" -ResourceGroupName "DNSRecords" -Ttl 60 -Overwrite -Force Add-AzureRmDnsRecordConfig -RecordSet $rs -Cname "MySomethingAzureWebsite.azurewebsites.net" Set-AzureRmDnsRecordSet -RecordSet $rs -Overwrite But how to I create CNAME records

not able to delete test cases in azure devops through powershell scripts

夙愿已清 提交于 2021-01-28 13:36:45
问题 I have checked How to delete multiple test cases in Azure DevOps It not works for me. Using PowerShell scripts alone, I want to delete multiple test cases in one go in Azure DevOps. Currently, portal only allows to delete one at a time. I have tried like below way, and throws exceptions. $url = "https://dev.azure.com/testarulmouzhie/testDemo_Project/_apis/test/testcases/21?api-version=5.0-preview.1" Invoke-RestMethod -Uri $url -Method Delete -ContentType application/json it throws error like

Get Windows DisplayLanguage with Powershell

拜拜、爱过 提交于 2021-01-28 12:54:33
问题 I am trying to get Windows Display Language setting via powershell. I tried Get-WinUserLanguageList but this returns the list of all languages. Get-WinSystemLocale and Get-Culture are also not the ones that i am looking for. Is there a way to get current display language? What i am looking for is this: 回答1: (Get-UICulture).Name or $PSUICulture Official Document Get-UICulture 来源: https://stackoverflow.com/questions/61675257/get-windows-displaylanguage-with-powershell

Windows WMI change the value of MotherBoard SerialNumber

…衆ロ難τιáo~ 提交于 2021-01-28 12:46:35
问题 Is it possible to change the Motherboard serialNumber value with WMI? $SN = Get-WmiObject Win32_BaseBoard $SN.SerialNumber="123456" $SN.put() $SN.SerialNumber The error I got was: Exception calling "Put" with "0" argument(s): "Provider is not capable of the attempted operation " 回答1: In short no. I wouldnt expect that to work. The properties of Win32_BaseBoard are read-only as per MSDN SerialNumber Data type: string Access type: Read-only Assuming your BIOS supports it, in most cases, you

Windows WMI change the value of MotherBoard SerialNumber

邮差的信 提交于 2021-01-28 12:42:56
问题 Is it possible to change the Motherboard serialNumber value with WMI? $SN = Get-WmiObject Win32_BaseBoard $SN.SerialNumber="123456" $SN.put() $SN.SerialNumber The error I got was: Exception calling "Put" with "0" argument(s): "Provider is not capable of the attempted operation " 回答1: In short no. I wouldnt expect that to work. The properties of Win32_BaseBoard are read-only as per MSDN SerialNumber Data type: string Access type: Read-only Assuming your BIOS supports it, in most cases, you