powershell

Adding a hyperlink to an email generated through PowerShell

只愿长相守 提交于 2021-02-10 15:13:44
问题 I have a script that currently does several things. It creates a user account in Active Directory, writes data to a SQL table and sends an email to the account requestor with the account's user name and password. We'd love to add a hyperlink to that email so that the requestor can click to view their original request form, but I can't quite seem to get the syntax right. Because double quotes are used in the PowerShell syntax as well as the HTML link, I defined the link as a variable and

Powershell update xml key value based on other key value

感情迁移 提交于 2021-02-10 14:57:14
问题 I'm trying to write some powershell that will update the value of a xml key value pair based on the value of another key value pair in the same node. Example xml: <?xml version="1.0" encoding="utf-8" ?> <configuration> <plugins> <plugin pluginType="plugin1" polling_internal="2" polling_unit="M" enabled="true"> <params> <add key="Server" value="server1.local" /> <add key="database" value="databasename1" /> </params> </plugin> <plugin pluginType="plugin2" polling_internal="2" polling_unit="M"

Powershell update xml key value based on other key value

独自空忆成欢 提交于 2021-02-10 14:55:13
问题 I'm trying to write some powershell that will update the value of a xml key value pair based on the value of another key value pair in the same node. Example xml: <?xml version="1.0" encoding="utf-8" ?> <configuration> <plugins> <plugin pluginType="plugin1" polling_internal="2" polling_unit="M" enabled="true"> <params> <add key="Server" value="server1.local" /> <add key="database" value="databasename1" /> </params> </plugin> <plugin pluginType="plugin2" polling_internal="2" polling_unit="M"

How to specify column position using import-csv in PowerShell

徘徊边缘 提交于 2021-02-10 14:33:22
问题 As I have many csv files and want to sort first column of csv file, in that case first column name may differ for each file. Hence how to specify the column position for sort the many different files. here is my script that I tried and am seeking like this code.($_.1) $InputFilePath = "C\test.csv" $OutputFolderPath ="C:\output.csv" $UniqueValue = Import-Csv $InputFilePath | Sort-Object -Property $_.1 | Export-Csv -Encoding Default -NoTypeInformation $OutputFolderPath 回答1: Two ways: Reflecting

Listing all azure vm belonging to particular subnet

女生的网名这么多〃 提交于 2021-02-10 14:22:57
问题 I want to list all azure vms in a particular subnet. I don't know how to write a PowerShell script for this. I am trying the below but it's not giving the desired output. My desired output- All VMs belonging to subnet having ip 10.87.00.01...10.87.99.99 should get listed in my text file subnet_VM.txt $tgtIP = "10.87.xx.xx" $vms = Get-AzureVM foreach($vm in $vms) { $vmIP = (Get-AzureVM -ServiceName $vm.ServiceName –Name $vm.Name).IpAddress foreach($ip in $vmIP) { if($ip -like '$tgtIP*') { $vm

Listing all azure vm belonging to particular subnet

房东的猫 提交于 2021-02-10 14:22:16
问题 I want to list all azure vms in a particular subnet. I don't know how to write a PowerShell script for this. I am trying the below but it's not giving the desired output. My desired output- All VMs belonging to subnet having ip 10.87.00.01...10.87.99.99 should get listed in my text file subnet_VM.txt $tgtIP = "10.87.xx.xx" $vms = Get-AzureVM foreach($vm in $vms) { $vmIP = (Get-AzureVM -ServiceName $vm.ServiceName –Name $vm.Name).IpAddress foreach($ip in $vmIP) { if($ip -like '$tgtIP*') { $vm

Listing all azure vm belonging to particular subnet

和自甴很熟 提交于 2021-02-10 14:22:09
问题 I want to list all azure vms in a particular subnet. I don't know how to write a PowerShell script for this. I am trying the below but it's not giving the desired output. My desired output- All VMs belonging to subnet having ip 10.87.00.01...10.87.99.99 should get listed in my text file subnet_VM.txt $tgtIP = "10.87.xx.xx" $vms = Get-AzureVM foreach($vm in $vms) { $vmIP = (Get-AzureVM -ServiceName $vm.ServiceName –Name $vm.Name).IpAddress foreach($ip in $vmIP) { if($ip -like '$tgtIP*') { $vm

Powershell Large File Creation to Size with Data [duplicate]

旧时模样 提交于 2021-02-10 14:19:41
问题 This question already has answers here : How to Generate File of a determinate Size in Windows? (3 answers) Closed 7 days ago . I am trying to determine what Powershell command would be equivalent to the following Linux Command for creation of a large file in a reasonable time with exact size AND populated with the given text input. New Question asked as this one was automatically closed for some reason. Given: $ cat line.txt !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_

Running Powershell from C# gives error: `running scripts is disabled on this system`

自古美人都是妖i 提交于 2021-02-10 12:38:43
问题 In my C# application, I try to create a RunSpace to invoke some Powershell scripts. However when it reaches the code to actually create it, it fails with the error below: var implementedHost = new implementedPSHost(); using (var rs = RunspaceFactory.CreateRunspace(customPSHost)) { cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https://go.microsoft.com/fwlink/?LinkID=135170.At line:1 char:3+ . .\Scripts\loadFunctions

Powershell, EWS, OAuth2, and automation

十年热恋 提交于 2021-02-10 11:48:47
问题 I am trying to find documentation on how to implement non-interactive Oauth2 authentication to EWS using PowerShell, but I'm probably not using the correct search terms, because I can't find anything useful. The Microsoft documentation I can find on OAuth2 only has C# documentation. So, does anyone know how to implement this? No user input, should work with input that can be provided as script input Should be in PowerShell, not C# Details! Details! Not 'Now generate a login token', but the