powershell-4.0

Test if Wireless Adapter is Working Before Resetting

。_饼干妹妹 提交于 2020-02-05 02:13:42
问题 Is there a simple way to prove if a network adapter is working? Perhaps some IP like localhost (127.0.0.1) which is always available regardless of which network I'm connected to; only one that only shows if my wireless network adapter's working? Or perhaps there's some simple diagnostic check to confirm this? I've tagged this question as PowerShell as that's my preferred language; but I can figure out ways to integrate with any other solutions which may be suggested. Tried so far I thought of

Powershell - Monthly Scheduled Task Trigger

这一生的挚爱 提交于 2020-01-29 09:46:08
问题 I'm currently automating the creation of scheduled tasks via Powershell, and I'm using the New-ScheduledTaskAction , New-ScheduledTaskTrigger , and Register-ScheduledTask commands. Now, I have a few jobs that need to run under the following conditions : Run once every Friday Run once on the 1st of every month Run once on the 10th day of every month While the technet documentation for the New-ScheduledTaskTrigger command specifies a Daily and Weekly time span parameter, I do not see one for

Directly Referencing Properties in Powershell 2.0

↘锁芯ラ 提交于 2020-01-21 20:41:50
问题 I encountered a bug in a script I wrote this morning where I wasn't getting an output from my Select-String expression. After a bit of playing I realized that this expression would not return the value of my match in v2.0 but would in v4.0 where I originally wrote it. ($log | Select-String "\[CIsoCreator\] Creating iso file" -AllMatches | Select-Object -ExpandProperty line -Last 1 | Select-String "([A-Z]\:)(.*\\)*.*\.iso").matches.value After trying a few things I ended up with this which

Directly Referencing Properties in Powershell 2.0

坚强是说给别人听的谎言 提交于 2020-01-21 20:41:12
问题 I encountered a bug in a script I wrote this morning where I wasn't getting an output from my Select-String expression. After a bit of playing I realized that this expression would not return the value of my match in v2.0 but would in v4.0 where I originally wrote it. ($log | Select-String "\[CIsoCreator\] Creating iso file" -AllMatches | Select-Object -ExpandProperty line -Last 1 | Select-String "([A-Z]\:)(.*\\)*.*\.iso").matches.value After trying a few things I ended up with this which

Extract value from JSON

邮差的信 提交于 2020-01-21 05:07:49
问题 I am trying to use PowerShell to extract value from JSON object, I have the following JSON: { "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#", "contentVersion": "1.0.0.0", "parameters": { "clusterName": { "value": "hbasehd35" }, "location": { "value": "East US 2" }, "clusterType": { "value": "hbase" }, "clusterVersion": { "value": "3.5" }, "clusterWorkerNodeCount": { "value": 5 }, "subnetName": { "value": "hbase-subnet" }, "headNodeSize": { "value

Extract value from JSON

被刻印的时光 ゝ 提交于 2020-01-21 05:06:31
问题 I am trying to use PowerShell to extract value from JSON object, I have the following JSON: { "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#", "contentVersion": "1.0.0.0", "parameters": { "clusterName": { "value": "hbasehd35" }, "location": { "value": "East US 2" }, "clusterType": { "value": "hbase" }, "clusterVersion": { "value": "3.5" }, "clusterWorkerNodeCount": { "value": 5 }, "subnetName": { "value": "hbase-subnet" }, "headNodeSize": { "value

How to count the result of a if loop within foreach loop

纵然是瞬间 提交于 2020-01-17 03:39:25
问题 Is there a better way to be able to count the amounts of empty groups than using this method and then calling $count + 1 for each result? I tried to mess around with $123.count but it kept returning 0 $Groups = Get-ADGroup -Properties * -Filter * | where { $_.Members.Count -eq 0} $123= Foreach($G In $Groups) { $Membership = Get-ADGroupMember -Identity $G.Name If($Membership.count -eq 0){ $Count = $count + 1 } } 回答1: Get-ADGroup can do much of what you ask without going away from AD. Getting

Get all DNS records associated with an IP

家住魔仙堡 提交于 2020-01-14 14:41:55
问题 Background The following code returns the IPv4 address of a given alias or host: [System.Net.Dns]::GetHostAddresses('someDnsName').IPAddressToString The below code returns the HostName (CName) and aliases of an IP: [System.Net.Dns]::GetHostByAddress('172.12.34.56') I'd therefore expect anything which returns an IP on GetHostAddresses to be listed under the HostName or Aliases of a call to GetHostByAddress (or at least for the FQDN of that item to be listed). i.e. I'd expect the result of the

Powershell - “Expressions are only allowed as the first element of a pipeline”

冷暖自知 提交于 2020-01-13 11:13:22
问题 Could someone please tell me how to avoid this error in the below circumstance? $codegenDir = "Z:\Desktop\Song-Renamer" $PowerShellRepresentation = dir -path $MyMusicFolder -recurse -include *.mp3,*.m4a,*.wma,*.flac,*.ape | select -ExpandProperty FullName | $codegenDir\codegen.exe -s 10 20 | Out-String | ConvertFrom-Json What completely puzzles me is if simply omit $codegenDir (see below), the code operates correctly. I "think" I understand the concept of placing the expression first (ahead

Powershell - “Expressions are only allowed as the first element of a pipeline”

两盒软妹~` 提交于 2020-01-13 11:12:04
问题 Could someone please tell me how to avoid this error in the below circumstance? $codegenDir = "Z:\Desktop\Song-Renamer" $PowerShellRepresentation = dir -path $MyMusicFolder -recurse -include *.mp3,*.m4a,*.wma,*.flac,*.ape | select -ExpandProperty FullName | $codegenDir\codegen.exe -s 10 20 | Out-String | ConvertFrom-Json What completely puzzles me is if simply omit $codegenDir (see below), the code operates correctly. I "think" I understand the concept of placing the expression first (ahead