hostname

Hostname Directory

Often when working with users, the need may arise to have the name of the computer (hostname). Users may not know where to find the name of the computer easily. This is a simple function to paste the hostname on the taskbar, which can also be used as a directory to store commonly used files or tools.

  1. Open a PowerShell window (does not need to be admin)
  2. Enter the following commands:

    • This sets the variable “dirName” with the path to the folder to create. The Env:ComputerName is an environmental variable which pulls the NetBIOS name.
    • The second command is a conditional statement that checks the filepath for a directory with a name that matches with the name set in the previous command. If there is no directory found, one is created.
  3. To paste it to the taskbar, right click on the taskbar >> select Toolbars (at the top) >> New Toolbar >> navigate to the directory just created, select it, and click Select Folder.
  4. The directory will be saved as a supplementary toolbar on the taskbar.
  5. To access the directory and save files there, right-click on the name (ON-ROC-LT30) and select Open Folder. That will open a File Explorer instance and allow the user to save files there.
  6. The name of the directory will not be automatically updated if the name of the computer is changed, the whole process would need to be run again.