Problem scenario
From a PowerShell prompt, you run a “bcdboot” command, but you see the message “Failure when attempting to copy boot files”.
Solution
1. Open PowerShell as an Administrator
2. Run the command again.
…
A Technical I.T./DevOps Blog
Problem scenario
From a PowerShell prompt, you run a “bcdboot” command, but you see the message “Failure when attempting to copy boot files”.
Solution
1. Open PowerShell as an Administrator
2. Run the command again.
…
Problem scenario
You have seen the PowerCLI -f option. What does it mean or do?
…-f ($_.SizeGB)…
Solution
It manipulates the format of the output of a PowerCLI command usually to make the output more readable; one purpose is to make the output consumable for another PowerCLI command.
(The answer was adapted from pages 114 and 115 of PowerCLI Cookbook by Sellers.)
…
Question
What does MoRef mean?
Answer
It is a portmanteau of “Managed Object Reference.” It is a data type that comes up in the context of alerts/alarms in vSphere.
(The answer was adapted from page 152 of PowerCLI Cookbook by Sellers.)
“MoRefs are unique identifiers assigned to objects at the time of their creation.” (Taken from page 202 of PowerCLI Cookbook by Sellers.)
…
Problem scenario
You are using either Windows Server 2019 or Windows 10. You want to know if UAC is enabled or not. What should you do?
Solution
Open PowerShell. Run this:
If((Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System).EnableLUA -eq 1) { echo “UAC is enabled”} Else {echo “UAC is NOT enabled”}
…
Continue reading “How Do You Find out if UAC is Enabled on Your Windows Computer?”
Problem scenario
You are running Windows Server 2019. You want to install Windows DSC. What do you do?
Solution
…
Continue reading “How Do You Install Windows DSC on Windows Server 2019?”
Problem scenario
Port 5986 is blocked from your Linux server to your Windows server. You have used the nmap command and see that it is filtered. You believe there are no intermediate firewalls or OS firewalls blocking this port. What should you do?
Solution
This assumes you have no firewall blocking port 5986 for incoming connections to the Windows server. nmap will report 5986 is filtered despite there being nothing blocking this port if wsman’s listener has not been properly configured.*
$hostName = $env:COMPUTERNAME
$serverCert = New-SelfSignedCertificate -CertStoreLocation Cert:\LocalMachine\My -DnsName $hostName
Export-Certificate -Cert $serverCert -FilePath c:\vagrant\PsRemoting-Cert1.cer
Get-ChildItem c:\vagrant\PsRemoting-Cert1.cer
Enable-PSRemoting -Force
New-Item -Path WSMan:\localhost\Listener\ -Transport HTTPS -Address * -CertificateThumbPrint $serverCert.Thumbprint -Force
…
Continue reading “How Do You Connect over Port 5986 on a Windows Server?”
Problem scenario
You want to run a PowerShell script or run an interactive command on a Windows server. You have Puppet Bolt installed on a Linux server. You do not need to use SSL. What do you do?
Solution
Run a command like this (but substitute x.x.x.x with the IP address of the Windows server, jdoe with the username and coolpassword with jdoe’s password):
bolt command run “Get-Process” –Targets winrm://x.x.x.x –no-ssl –user jdoe –password coolpassword
To run a script called “cool.ps1”,
…
Continue reading “How Do You Run a Bolt Command from a Linux Server to a Windows Server?”
PowerShell for Sysadmins: Workflow Automation Made Easy by No Starch Press
Learn Windows PowerShell in a Month of Lunches by Manning Publications
Windows PowerShell Cookbook: The Complete Guide to Scripting Microsoft’s Command Shell by O’Reilly Media
Mastering Windows PowerShell Scripting: Automate and manage your environment using PowerShell Core 6.0, 3rd Edition by Packt Publishing
Windows PowerShell and Scripting for Beginners: Complete Beginners Guide to learn Windows PowerShell and its Scripting by Independently published
Learn PowerShell Scripting in a Month of Lunches by Manning Publications
Windows PowerShell Step by Step by Microsoft Press
Problem scenario
You want to do a regex with PowerShell. Using PowerShell, how do you retreive all .txt files that have the sequence of characters “foobar” in them?
Solution
Run a command like this:
Select-String -Path c:*.txt -pattern foobar
This solution was adapted from this external website.
…
Continue reading “How Do You Find Files with a Specific Pattern of Text?”
Problem scenario
Using PowerShell, how do you retrieve all files that are greater than 20 MB?
Solution
Run a command like this:
Get-ChildItem C:\ -recurse | where-object {$_.length -gt 20971520} | Sort-Object length | ft fullname, length -auto
This was adapted from this external website.
…
Continue reading “How Do You Find Files on the C: Drive That Are Greater than 20 MB?”