Stephen joined the group
PowerShell 1 day, 5 hours ago
Emanuel Halapciuc commented on
Change remote IP address and DNS entry with a PowerShell script 1 day, 12 hours ago
Well, I also introduced you to filtering. And I’d definitely use Where-Object instead of more convoluted syntax and arrays for that purpose.
Those are great tools and just as essential for other purposed, but not for this. I mentioned them here just to show there are more ways to accomplish something. And I also mentioned there are more ways, and that you should use the most suitable one for each case. 🙂Lee Roy Anthony commented on
Change remote IP address and DNS entry with a PowerShell script 1 day, 14 hours ago
I meant ‘forcing the codes’. Sorry for the typo.
Lee Roy Anthony commented on
Change remote IP address and DNS entry with a PowerShell script 1 day, 14 hours ago
I meant ‘forcing the codes…’. Sorry for the typo.
Lee Roy Anthony commented on
Change remote IP address and DNS entry with a PowerShell script 1 day, 14 hours ago
Hi Emanuel!
While happily looking at what I’ve been learning, there’s this realization (and warning) that I’m forching the codes to just ‘stop’ at the 1st record/occurence of ‘Ethernet 2’. What if there’s more? What if the value ‘Ethernet 2’ appears on the 2nd, 3rd, so on…? How will I be able to capture it if it’s not on the 1st record? Meaning, how will I be able to capture ‘Ethernet 2’ in InterfaceAlias when/if I don’t know when it will appear?
You’ve introduced me to string formatting in your latest reply. Thank you!
Fox system commented on
WSUS reporting with PowerShell 4 days, 5 hours ago
Hi Alex, I’m telling you that I also have the same error as Luciano, but in my case, according to your comment, I don’t use a signature certificate on my server. ?
Raza commented on
Create a customized Windows 10 image using PowerShell and Hyper-V 4 days, 10 hours ago
Hi Wolfgang
When i try to personalize things, it is asking for product key.In my last article, we created a new VM for Kali Linux, mounted the ISO file to its virtual DVD drive, and changed the boot order so that the VM could boot from the virtual DVD drive. Here, I will show how to start and stop a Hyper-V with PowerShell. You’ll also learn how to disable secure boot with PowerShell.
Emanuel Halapciuc commented on
Change remote IP address and DNS entry with a PowerShell script 4 days, 15 hours ago
Good, finally! :))
You could have also done
Get-NetAdapter | where InterfaceAlias -like “Ethernet 2”
or whatever the NIC Alias was.
Or
(Get-NetAdapter)[0].InterfaceAlias
This one is less nice and a bit unpredictable, but it does the same thing.There are many ways to achieve something. In the long run, I’d suggest you pick an option that’s reasonably fast and easy to understand for a colleague that’s looking at a script (or you in 6 months, like Mr. Jeff Hicks always says).
Lee Roy Anthony commented on
Change remote IP address and DNS entry with a PowerShell script 4 days, 15 hours ago
Hi Emanuel!
I finally got it!
I just had to use Select-Object’s limiter command!
PS C:Windowssystem32> Invoke-Command -VMName Win10VMTest004 -ScriptBlock {
$InterfaceAlias2 = Get-NetAdapter | Select-Object -First 1 -ExpandProperty InterfaceAlias
$InterfaceIndex2 = Get-NetAdapter | Select-Object -First 1 -ExpandProperty InterfaceIndex
If ($InterfaceAlias2 -eq “Ethernet 2”)
{
$InterfaceIndex4Set = $InterfaceIndex2
Write-Output $InterfaceIndex4Set, $InterfaceAlias2
}}
cmdlet Invoke-Command at command pipeline position 1
Supply values for the following parameters:
7
Ethernet 2This solution I got just from browsing backwards to the basics!
Thank you!!!
Lee Roy Anthony commented on
Change remote IP address and DNS entry with a PowerShell script 4 days, 20 hours ago
Hi Emanuel!
You’re right. 🙂
These codes are meant to simulate if I’ll be able to get the value of InterfaceIndex once I encounter a value of ‘Ethernet 2’ in InterfaceAlias. I’ve made $InterfaceIndex4Set just so I can ‘see’ what’s inside it, after the movement of whatever is inside of InterfaceIndex. However, the obvious obstacle for me is that InterfaceIndex keeps on giving out 2 values, which is ‘7’ and ‘4’. I only need the 1st value of ‘7’ to appear once the IF statement gets satisfied with an InterfaceAlias value of ‘Ethernet 2’.
What I want to do is to get all InterfaceAlias ‘Ethernet 2’ (and nothing else) and then use it’s corresponding InterfaceIndex, which should also have one value only. But I always get 2 values.
Thank you!
Emanuel Halapciuc commented on
Change remote IP address and DNS entry with a PowerShell script 5 days, 13 hours ago
Well, if you have more than one NIC, then you have an array. To be honest, I’m not very sure about what you’re doing (like what is $InterfaceIndex4Set).
I think before you get into deeper stuff it would help you greatly to get more comfortable with the basic workings of PowerShell. Otherwise you’d try to drive a Formula 1 car after you just got your driver’s license.
Until then, even if you get something right (or it would seem to be right), then the result of your script might not be what it seems, and it could come back to haunt you. Usually that happens right before you plan to go on vacation, or immediately after. 🙂
Lee Roy Anthony commented on
Change remote IP address and DNS entry with a PowerShell script 6 days, 16 hours ago
HI Emanuel!
Thank you!!!
With your expert guidance, I was able to come up with this:
PS C:Windowssystem32> Invoke-Command -VMName Win10VMTest004 -ScriptBlock {
$InterfaceIndex2 = Get-NetAdapter | Select-Object -ExpandProperty InterfaceIndex
$InterfaceAlias2 = Get-NetAdapter | Select-Object -ExpandProperty InterfaceAlias
If ($InterfaceAlias2 -eq “Ethernet 2”)
{
$InterfaceIndex4Set = $InterfaceIndex2
Write-Output $InterfaceIndex4Set, $InterfaceAlias2
}}
cmdlet Invoke-Command at command pipeline position 1
Supply values for the following parameters:
7
4
Ethernet 2
EthernetPS C:Windowssystem32>
What I need is to ‘do something’ once I catch InterfaceAlias value of Ethernet 2, and it’s basically using the InterfaceIndex value of ‘7’ somewhere down the road.
So I have very obvious questions in here. Am I dealing with an array when I access the contents of Get-NetAdapter? How do I ‘capture’ the same ‘row’ of data once I get the ‘Ethernet 2’ value of InterfaceAlias? Sorry about my ignorance. I did COBOL programming and as you can see, my knowledge is pretty Jurassic at best. 😉
Thank you again!
Thank you for writing this article.
I wrote all my own Powershell code to install VMs, but on the free Hypervisor-only platform. IMO, it is pointless to host VMs on a GUI based server. The command line based server has far less bloat and better security.Michael Pietroforte edited the doc How to create a Hyper-V VM with PowerShell in the group
PowerShell 1 week, 1 day ago
In this new post of my Hyper-V management series, I will explain how create a Hyper-VM with PowerShell.
If you’re creating complex PowerShell scripts like this, you should already be aware that setting the AllowTelemetry key in the registry, will have the same effect as using the Local Group Policy Editor to set one on of the 4 allowed levels of Data Reporting. You should also be aware that setting it to Zero is only possible on Windows Enterprise and if you choose to do it anyway…. for example, if you set this key to 0 on a Windows Pro copy…. the system will revert to the level of Diagnostic Data that Microsoft sees fit, and this effect will be invisible. You can verify what I’m telling you by simply visiting the relevant Group Policy, setting it to 4 then refresh Regedit (press F5) and watch as the AllowTelemetry key changes to 4. If you’re not on Enterprise then then 1 is the lowest setting you can use.
Basically, if you don’t know what you’re doing by poking around in the registry, you may very well be enabling more Telemetry while you think you’re turning it off.
Key: HKLMSOFTWAREPoliciesMicrosoftWindowsDataCollection”AllowTelemetry”
Local Group Policy: Computer ConfigurationAdministrative TemplatesWindows ComponentsData Collection and Preview BuildsAllow Telemetry (it tells you that you can only set 0 if you’re running Enterprise.)
*I’d never recommend that anybody run a script that automatically makes a bunch of changes to their Windows in the hopes of tuning it for privacy reasons. The best thing to do is do the research yourself and understand what it is that you’ll be changing.
thank you great article
Nevor Yard commented on
How to create an open file/folder dialog box with PowerShell 1 week, 4 days ago
Try this:
start $FileBrowser.filename
Robert Pearman wrote a new post,
Remove or block Chrome extensions with PowerShell 1 week, 5 days ago
A comment on the previous post about deploying Chrome extensions posed the question of whether PowerShell could be used to remove Chrome extensions.
- Load More