- The default value of $WhatIfPreference variable is $false.
- Adding “$WhatIfPreference = $true” to a script or the PowerShell profile
- Now every cmdlet that supports a whatif switch will execute as the whatif switch is on
- To overwrite the setting in a particular cmdlet, add –whatif:false in the cmdlet
Search This Blog
Use $WhatIfPreference in PowerShell to Prevent Accidents
PowerShell ExecutionPolicy Bypass
Windows PowerShell v.2 supports a bypass execution policy. It can be used to overwrite the computer execution policy setting in batch script.
The computer execution policy is restricted. A PowerShell script can not be executed.
With the bypass option, the script is able to execute.
PowerShell: Avoid Bank Lines at End of a Text File
Use System.IO.File .NET Framework class’s Write AllText static method.
[System.IO.File]::WriteAllText(string path, string contents)
or [System.IO.File]::WriteAllText(string path, string contents, System.Text.Encoding encoding)
e.g. [system.io.file]::WriteAllText(“c:\fso\ioascii.txt”, $count, [System.Text.Encoding]::ascii)
More info: [system.io.file] | get-member –static WriteAllText | fl *
[system.text.encoding] | get-member –static –MemberType property
Best Practices for DNS Client Setting in Windows Server Domain Controller with DNS Installed
Assume at least two domain controllers with DNS installed in the domain.
- Configure the remote DNS server set as Preferred DNS server
- Configure 127.0.0.1 as Alternate DNS server
Reference:
Use WinSCP to Transfer Files in vCSA 6.7
This is a quick update on my previous post “ Use WinSCP to Transfer Files in vCSA 6.5 ”. When I try the same SFTP server setting in vCSA 6.7...
-
Recently, we created a new child domain in the existing AD forest with two new Windows Server 2012 R2 domain controllers. The AD authenticat...
-
find out the name of vSphere host running the stuck task if possible SSH to the vCenter Server server appliance service vmware-vpxd resta...
-
Updated on 07/13/2016. See the update this post, I might find the ultimate solution, even I am still not sure what the cause of the issue. ...