Skip to main content

Posts

Showing posts from January, 2022

PowerShell test/check if file exist

One liner code to check if file exists via PowerShell. Code below will check if Winrar.exe exist on the path specified. if (-not (test-path "$env:C:\Program Files\WinRAR\winrar.exe")) {write-host "File not found"; break;} {write-host "File Found" } Output will show "File Found" if winrar.exe exists on the path specified. The "break;" command on the code will cause the script to exit and not to continue to show "File Found" if the file doesn't exist. Or else it will be confusing to see the output. However, if the file can be found then the "File not Found" will not be shown. PowerShell will automatically bypass the first command on the { } curly braces and execute whatever is on the next line. Code below will check if output.txt exist on c:\temp. if (-not (test-path "$env:C:\temp\output.txt")) {write-host "File not found"; break;} {write-host "File Found" } Output ...

Enable/Disable NICs from Windows command line

First thing to do is to get or list all NICs available on the system. This must be done by opening or running the command in an elevated command prompt. Check out links below on how to open an Elevated Command Prompt. https://quickbytesstuff.blogspot.com/2014/10/open-elevated-command-prompt.html https://quickbytesstuff.blogspot.com/2018/06/how-to-open-elevated-command-prompt.html Why need to open an elevated CMD? Some commands needs to be run by a person who understands what he or she is doing. Or simply, some commands are for Sys Admin or IT personnel who are tasked to control or manage the system. So, commands has to be run on a elevated cmd which has an admin privileges. Here's how to enable or disable NIC interfaces on a Windows system via CLI. First, open an Elevated CMD. Then need to list, show or get all the available NIC on the system. Get NIC list and index number: wmic nic get name, index Sample Output of the above command: C:\WINDOWS\system32...

Excel PDF web links not working

Excel is an spreadsheet tool. However, it can also be useful to as a word or a text editor. Such as creating a simple file with links, URLs or website name and saving the file as PDF. One way to create PDF is by printing the file and selecting a PDF printer and of course the file will be in PDF format. In some cases, after printing to PDF the URLs or website links may not work. Or the text hyperlink is not clickable. Other way to save the file as PDF in Word or Excel is to used the "save as" option and save the file as PDF. To save the Excel file as PDF and to preserve the Hyperlinks or make the link clickable in PDF, follow the steps below. - On the Excel file, click "File" - This will open a few options and "save as" is one of them - After clicking "save as", it will show the option where to save the document - You can click "This PC" and select "Documents" - The file will be saved on Documents folder - Afte...