Category Archives: Win10

Show “Copy as Path” Always in Right-Click Menu Without Shift Key » Winhelponline

Show “Copy as Path” Always in Right-Click Menu Without Shift Key

This post tells you how to always show the Copy Path option in the right-click menu by default in Windows 10, without needing to press Shift every time.

The much useful “Copy as Path” built-in context menu exists in all versions of Windows. It’s an extended command which means you need to hold down the Shift key to access the extended menu item. Press and hold Shift, and right-click on a file or folder. Click “Copy as Path option” in the context menu. The object’s (file or folder) full path is now copied to the Clipboard.

Here is how the standard “Copy as Path” option appears.

copy-as-path-always-show-windows-10
Copy as path right-click menu with Shift pressed.

Always Show “Copy as Path” in the Right-click Menu

If you frequently use Copy as Path, having to access it by pressing the Shift key every time can be annoying like hell. There is a registry tweak to show the menu by default without having to press the Shift key down.

  1. Copy the following lines to Notepad.
    Windows Registry Editor Version 5.00
    
    ;Show Copy as Path always in the right-click menu, without pressing SHIFT
    ;Ramesh Srinivasan, Winhelponline.com
    
    [HKEY_CLASSES_ROOT\Allfilesystemobjects\shell\windows.copyaspath]
    @="Copy &as path"
    "Icon"="imageres.dll,-5302"
    "InvokeCommandOnSelection"=dword:00000001
    "VerbHandler"="{f3d06e7c-1e45-4a26-847e-f9fcdee59be0}"
    "VerbName"="copyaspath"
    
  2. Save the file as copyaspath.reg – see also How to use .REG files
  3. Double-click the registry file to run it.

Here is how the new “Copy as path” command appears in the context menu of a file or folder.

copy-as-path-always-show-windows-10
Copy as Path menu option without using Shift.

(The above registry tweak is based on the article How to Add a Ribbon Command to Right-click Menu)

Optionally, you can customize the menu icon by editing the “Icon” path in the REG file or the registry directly.

Send-MailMessage: The PowerShell Way to Send Email

The SMTP Server

All email has to go through an SMTP server somewhere via a server and a port. To specify a the SMTP server to use, use a parameter called SMTPServer that allows you to specify the SMTP server to establish a connection and relay mail through. However, it is not required.

If you don’t specify a value for the SMTPServer parameter, the value stored in the $PSEmailServer preference variable will be used. You can assign a value to this variable just like you would any other variable.

Assigning a value to the $PSEmailServer preference variable
PS51> $PSEmailServer = 'smtp.server.local'

However, this variable does not live across PowerShell sessions. This means you must define it every time a new PowerShell session is open. For this reason, I recommend either using it by defining it above your Send-MailMessage reference or not defining it all. Instead, I’d personally provide the SMTPServer parameter value. This way you don’t have to manage an outside variable that might change on you.

PS51> Send-MailMessage -SmtpServer 'smtp.server.local'

Port

By default, the value that the cmdlet will attempt to send an email through the SMTP server is port 25. This is plain, unencrypted SMTP. However, nowadays, it’s more common to send encrypted email using SSL/TLS (We’ll cover these scenarios later).

If you need to change the port from 25, you can use the Port parameter.

PS51> Send-MailMessage -SmtpServer 'smtp.server.local' -Port 587

Recipients and Originators

To send an email to different recipients via methods like the ToCc and Bcc fields, the cmdlet has various parameters to accommodate this.

The To, Cc and Bcc Parameters in the Send-Mailmessage Cmdlet

The cmdlet has three parameters each supporting multiple recipients separated by a comma called ToCc and Bcc.

You can specify single addresses like below.

Sending email to one recipient via To, Cc and Bcc
PS51> Send-MailMessage -To joe@gmail.com -Cc bob@gmail.com -Bcc susie@hotmail.com -Subject 'this is a subject'

Or you can specify multiple recipients for each parameter value.

Sending email to multiple recipients via To, Cc and Bcc
PS51> Send-MailMessage -To joe@gmail.com, tony@mycompany.local -Cc bob@gmail.com, rick@othercompany.com -Bcc susie@hotmail.com,secret@fooorg.org -Subject 'this is a subject'

The From Parameter

When sending email, you can also specify the From parameter which will set the reply-to header in the email. This parameter only allows one address. Should a recipient choose to reply to the email, this will be the email address that reply will come back to.

Sending email from an address
PS51> Send-MailMessage -From me@company.org -To joe@gmail.com -Subject 'this is a subject'

By default, using an email address will simply show the email address in the recipient’s FROM field. However, if you’d like to specify a name or some kind of label like Service Account Mailbox, you may also specify a name and an email like:

Adam Bertram <adbertram@gmail.com>

Notice that the Subject parameter was used. This parameter is always required. You’ll see this parameter used in all examples.

Body

The Body parameter allows you to specify what will be in the email body. At the most simplest, you can specify any text you’d like and the cmdlet will send it via plaintext.

PS51> Send-MailMessage -From me@company.org -To joe@gmail.com -Subject 'this is a subject' -Body 'this is the body'

Sending HTML Body Emails

You can also send an email body via HTML rather than plaintext. To do that, use the same Body parameter as you would with plaintext but use HTML for the string and use the BodyAsHtml switch parameter.

Sending an HTML table in an email
$body = @'
<table style="width:100%">
  <tr>
    <th>Firstname</th>
    <th>Lastname</th> 
    <th>Age</th>
  </tr>
  <tr>
    <td>Jill</td>
    <td>Smith</td> 
    <td>50</td>
  </tr>
  <tr>
    <td>Eve</td>
    <td>Jackson</td> 
    <td>94</td>
  </tr>
</table>
'@

PS51> Send-MailMessage -From me@company.org -To joe@gmail.com -Subject 'this is a subject' -Body $body -BodyAsHtml

Notice in the above example, I enclosed the body string in @' and '@. This is called a here string. This allows you to define long strings typically seen in email bodies that contain carriage returns. Here strings preserve formatting of strings and is a great way to define the email body especially if it’s in HTML.

Encoding

If you have special characters in the subject or body of your email, you can use the Encoding parameter. This parameter allows you to encode the email subject and body via the specified encoding type before sending.

You have a few options here:

  • ASCII (default)
  • UTF8
  • UTF7
  • UTF32
  • Unicode
  • BigEndianUnicode
  • Default
  • OEM
PS51> Send-MailMessage -From me@company.org -To joe@gmail.com -Subject 'this is a subject' -Body 'this is the body' -Encoding UTF8

Attachments

The cmdlet can also attach one or more files. To do so, you can use the Attachments parameter and provide the path to the file(s) you’d like to attach.

Attaching the C:\file.doc to an email
PS51> Send-MailMessage -From me@company.org -To joe@gmail.com -Subject 'this is a subject' -Body 'this is the body' -Attachments 'C:\file.doc'

You can also specify multiple attachments via a collection by separating them with a comma.

Attaching the C:\file.doc and D:\report.xlsx file to an email
PS51> Send-MailMessage -From me@company.org -To joe@gmail.com -Subject 'this is a subject' -Body 'this is the body' -Attachments 'C:\file.doc','D:\report.xlsx'

The Attachments parameter also allows you to pipe files via cmdlets like Get-Item and Get-ChildItem to the Send-MailMessage cmdlet as well.

PS51> Get-ChildItem -Path 'C:\MyFiles' | Send-MailMessage -From me@company.org -To joe@gmail.com -Subject 'this is a subject' -Body 'this is the body'

Secure and Authenticated Email

By default, the cmdlet sends email via unencrypted SMTP communication over port 25. However, it also has support for sending encrypted email via SSL/TLS with a username and password.

If you attempt to relay email through an SMTP server that requires authentication, the command fails with an error message like below.

Error message when attempting to send unencrypted email.
The SMTP server requires a secure connection or the client was not
authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first.

To remedy this, you must first specify the port (typically 587 for TLS) and the UseSsl parameter. This tells the cmdlet to attempt to connect to port 587 on the SMTP Server and encrypt the entire message. You will typically (always?) also need to specify the username/password to authenticate to the SMTP server by using the Credential parameter.

PS51> $credential = Get-Credential
PS51> Send-MailMessage -From me@company.org -To joe@gmail.com -Subject 'this is a subject' -Body 'this is the body' -UseSsl -Port 587 -Credential $credential

Above I’m grabbing a credential (PSCredential) object using the Get-Credential cmdlet. This sometimes poses a problem because it’s interactive meaning it stops the script to ask for a username and password. To prevent this, you could create a PSCredential object on the fly.

A common email example is to use Gmail. Using the knowledge you’ve gained above, you can now easily send email through Gmail using the smtp.gmail.com SMTP server as shown below.

$gmailCred = Get-Credential

$sendMailParams = @{
    From = 'adbertram@gmail.com' ## Must be gmail.com
    To = 'someemail@domain.com'
    Subject = 'some subject'
    Body = 'some body'
    SMTPServer = 'smtp.gmail.com'
    SMTPPort = 587
    UseSsl = $true
    Credential = $gmailCred
}

Send-MailMessage @sendMailParams

Assigning Email Priority

Although one feature of email I personally wish would die, you can assign priority levels to the emails you send via the Priority parameter. This priority is then interpreted in various ways by the email client.

High priority message in Outlook
High priority message in Outlook

Send-mailmessage allows you to assign an email with three different priorities.

  • Normal (default)
  • High
  • Low
Assigning a high-priority email
PS51> Send-MailMessage -From me@company.org -To joe@gmail.com -Subject 'this is a subject' -Body 'this is the body' -Priority High

But please, for the love of God, don’t think all of your emails are high priority!

Delivery Notifications

Finally, you can specify delivery notifications for emails. Delivery notifications are what’s typically known as read receipts in some email clients. Delivery notifications allow you to be notified if/when the email is received by the recipient. However, the recipient must still allow it.

You have four options when requesting delivery notifications.

  • None (default)
  • OnSuccess (when the email is delivery is successful)
  • OnFailure (notify if the delivery is unsuccessful)
  • Delay (when the email is delayed via an SMTP server)

You can specify a delivery notification option by using the DeliveryNotificationOptions parameter.

Requesting a notification on delivery
PS51> Send-MailMessage -From me@company.org -To joe@gmail.com -Subject 'this is a subject' -Body 'this is the body' -DeliveryNotificationsOptions 'OnSuccess'

You can also request multiple delivery notifications at once by separating them with a comma.

Requesting a notification for all types
PS51> Send-MailMessage -From me@company.org -To joe@gmail.com -Subject 'this is a subject' -Body 'this is the body' -DeliveryNotificationsOptions 'OnSuccess','OnFailure','Delay'

Summary

In this post, you learned all about the Send-mailmessage cmdlet and what it can. We covered this cmdlet extensively using every parameter it has along with examples. I hope this post can server as a reference for you when using the Send-mailmessage cmdlet.

Further Reading

Be sure to check out some other related posts!

Source: Send-MailMessage: The PowerShell Way to Send Email

“Your administrator has blocked this application because it potentially poses a security risk to your computer” 

“Your administrator has blocked this application because it potentially poses a security risk to your computer”

Issue:

During the installation of BIM 360 Glue Desktop, you see this error message:

Application Install – Security Warning
Your administrator has blocked this application because it potentially poses a security risk to your computer.

Security Warning when installing BIM 360 Glue desktop app

Causes:

The Windows ClickOnce trust prompt is disabled. ClickOnce, a component of the .NET Framework, must be enabled to run BIM 360 Glue.

Solution:

To resolve the issue, enable this registry key:

  • HKLM\SOFTWARE\MICROSOFT\.NETFramework\Security\TrustManager‌​\PromptingLevel\Inte‌​rnet

Note: This operation should be performed by an administrator with a technical understanding of the Windows Registry.

To enable the registry key:

  1. Open the registry editor:
  2. Find the following registry key:

    \HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\.NETFramework\Security\TrustManager\PromptingLevel\Internet

    If the key does not exist, create it.

  3. Set the value to Enabled.

Warning!
Problems caused by improperly editing the Windows registry could render your computer operating system unusable. Microsoft provides a wealth of critical information that you need to know about the registry in the Microsoft Knowledgebase. Use the Microsoft Registry Editor only at your own risk and only after backing up the registry as outlined for your operating system in the Microsoft article How to back up and restore the registry in Windows and in the related solution How to back up the system registry. Additional information about the registry is also contained in the Help topics in the Microsoft Registry Editor.

Source: “Your administrator has blocked this application because it potentially poses a security risk to your computer” when installing BIM 360 Glue | BIM 360 | Autodesk Knowledge Network

What does Robocopy mean by tweaked, lonely, and extra? 

The Robocopy documentation for the option /it is simply “Includes ‘tweaked’ files”. What does “tweaked” mean?

The Robocopy documentation for the option /xl is simply “Excludes ‘lonely’ files and directories”. What does “lonely” mean?

“Tweaked”:

A Tweaked file is defined to be one that exists in both the source and destination, with identical size and timestamp, but different attribute settings.

“Lonely”:

A “lonely” file is present in source but not destination; excluding lonely will prevent any new files being added to the destination.

“Extra” (the other one that isn’t explained well):

An “extra” file is present in destination but not source; excluding extras will prevent any deletions from the destination.

Source: What does Robocopy mean by tweaked, lonely, and extra? – Super User

Suggested Robocopy Switches Explained | RainingForks Tech Blog

Suggested Robocopy Switches Explained

Windows’ robocopy.exe is a great command line program to quickly copy or fully backup your files, but there’s a lot of confusion out there about how to use its (not very well-documented) switches.  Here’s just what you need to know:

 

First of all, you probably already know that typing “robocopy /?” will give you a long list of switches to choose from.  Start there if you’re confused.  But since there are a LOT of choices, and they’re not well-explained, here’s a run-down of what I typically use, as I go about my day as an IT guy:

The basic format is: robocopy <source path> <destination path> <switches>

NOTE: I’ve found that using robocopy to copy across a network doesn’t always work using mapped drives!  Instead, use the full path (especially important when running as a Task in Windows Task Manager). For example, instead of “robocopy C:\Foo S:\Foo” do this: “robocopy C:\Foo \\SERVER\Foo

Another tip is if you’re using file paths that contain spaces, then you need to enclose each path in quotes. If no spaces, then quotes are optional.

/FFT is necessary to copy between file systems, such as Windows’ NTFS and Linux’s EXT4. If you don’t use this you can get wierdness like files looking like they’re newer than they really are, etc., since the two file systems keep time differently.

/COPYALL copies ALL aspects of the file/directory, including ownership and permissions info. Required if you’re backing up a server or something that you want to maintain group/user permissions, etc. for. (NOTE: Don’t use this switch when copying files from Linux to Windows if you aren’t logged in as the same user with admin rights on both machines! If you do, you’ll get a lot of errors like “A required privilege is not held by the client” and “The revision level is unknown” as it creates a bunch of empty folders at your Windows destination, but skips copying all your files! Instead you can use the /COPY:DT mentioned below, and if you really need to backup your Linux ownership & permissions info, save all the files in a tarball and then just backup that single file containing the directories & files with their attributes intact to Windows.)

/COPY:DT to just copy files & date/time stamps. This is good if you’re just copying some files to give to a friend, and don’t need permissions, etc. copied. Also good for copying files from Linux to Windows (see “note” in /COPYALL above).

/FP outputs the full path so you can more easily see where it is while it’s running.

/MIR exactly mirrors the files & directories, so things at the destination will be deleted if they’re not at the source. (This is the same as using /PURGE (which deletes stuff at the destination that doesn’t match) with /E (which includes Empty subdirectories)

/ZB tells robocopy to use restartable mode (which you want for large files, especially over WAN/unstable connections, since it’ll try to pick up where it left off if the connection gets dropped or there’s corruption mid-copy), and if access is denied, then it’ll use Backup mode, which allows you to copy files you might otherwise not have access to, assuming it’s being run under an account with sufficient privileges (e.g., member of Backup Operators, Administrators, etc.). (NOTE: the /Z switch sometimes slows down the copy speed, so if you don’t need it, don’t use it, especially if you feel like your Robocopy job is taking longer than it should. Sometimes there’s no speed difference, and sometimes it can be dramatic.)

/MT stands for Multi-Threaded, and tells robocopy to copy multiple files at once. The default number of threads is 8 (max is 128), but be careful, as running this over a network can really saturate your bandwidth, leaving none for anyone else. As a result, you may want to skip this one or try specifying less threads by doing something like /MT:2 which will just run two threads (instead of 1, which is what you get if you omit /MT entirely). (NOTE: This is only available in newer versions of Robocopy (Win7/2008R2 and later).  If you’re running older versions (or just don’t feel like bothering with this switch), you can simply open multiple command prompt windows and run it in multiple instances – I often will run two or three Robocopy batch files simultaneously. Also, this switch will make file copy progress numbers confusing, so it’s best to use the /NP switch mentioned below to disable outputting the copy’s progress. Some people speculate that running multiple threads can increase fragmentation, but I haven’t seen any hard evidence of this, and with increasing adoption of solid state drives, it may not matter for much longer anyway.)

/R:1 /W:3 are two switches you probably want to use together to tell robocopy how many times to retry accessing a file (1 in this example), and how long to wait between retries (3 seconds in this example).  If you leave this out, it’ll retry 1 million times with a 30 second wait between each one when it encounters a file it can’t access!!!

/XD is what you use when you want to tell robocopy to skip (i.e., exclude) a directory. Just follow /XD with a space and then the path to what you want excluded. If there are multiple directories you’d like to skip, separate them with a space. For example: /XD “C:\Foo\private stuff” “C:\Foo\plans for world domination”

/LOG:C:\LogFileName.txt /TEE /NP are three switches you’ll want to use together if you want to write the results of the copy to a log file (called “C:\LogFIleName.txt” in this example). If you want it to write what’s happening to the screen as well as to the log file, then you’ll also want to include /TEE.  And, possibly most importantly, you want to include /NP in there so that it does NOT show the progress as each file copies. If you leave this out, then your log file will be filled with every single percentage complete it displays! So you’ll have something like this: “0.0% 0.1% 0.2%” and so on, to 100% FOR EACH FILE, which is nuts.

Finally, if you want to append log file output to the end of an existing file, rather than creating a new file every time, you can modify the above line to include a plus sign, like so: /LOG+:C:\LogFileName.txt

That’s pretty much all you need to know! I figured most of this out from trial & error, as well as some internet searches. Unfortunately, I’ve read so many incorrect, or confused posts about robocopy on the internet over the years, that I wanted to write this to set things straight.  Hopefully you find this helpful – if nothing else, at least I’ll now have a handy reference for the next time I need to put together a robocopy command… 😉

Source: Suggested Robocopy Switches Explained | RainingForks Tech Blog

How To Install Windows Apps Without a Microsoft Account – CCM

How To Install Windows Apps Without a Local Account

  • Right-click on the Start menu to display your Power User options. Select the Run command. Next, type in
    regedit

    followed by Enter to open the Registry Editor:

  • Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System.
  • Click on the Edit menu, followed by New > DWORD (32-bit) Value. Rename the new key as MSAOptional:

  • Set the value of MSAOptional to 1. This will make your Microsoft accounts optional:

  • Close the Registry Editor and restart your computer. Once your computer loads, open the Windows Store and search for your desired app. Skip the sign-up procedure and proceed directly to your download.

Source: How To Install Windows Apps Without a Microsoft Account – CCM

Some stuff about things