• Home
  • Cloud VPS
    • Hong Kong VPS
    • US VPS
  • Dedicated Servers
    • Hong Kong Servers
    • US Servers
    • Singapore Servers
    • Japan Servers
  • Company
    • Contact Us
    • Blog
logo logo
  • Home
  • Cloud VPS
    • Hong Kong VPS
    • US VPS
  • Dedicated Servers
    • Hong Kong Servers
    • US Servers
    • Singapore Servers
    • Japan Servers
  • Company
    • Contact Us
    • Blog
ENEN
  • 简体简体
  • 繁體繁體
Client Area

PowerShell Command: New-SmbMapping

December 16, 2023

PowerShell Command: New-SmbMapping

When it comes to managing network shares in a Windows environment, the PowerShell command New-SmbMapping is an essential tool for system administrators. This command allows you to create a new Server Message Block (SMB) mapping on the local computer, which can be used to access shared folders on remote servers. In this article, we will explore the New-SmbMapping command in detail, providing relevant examples and code samples to help you understand how to use it effectively.

What is SMB?

Before we dive into the New-SmbMapping command, let’s first understand what SMB is. SMB, or Server Message Block, is a network file sharing protocol that allows applications to read and write to files and request services from server programs in a computer network. SMB is commonly used in Windows environments to share files and printers among networked computers.

Using the New-SmbMapping Command

The New-SmbMapping command is used to create a new SMB mapping on the local computer. This mapping can be used to access shared folders on remote servers. The command has several parameters that allow you to specify the details of the mapping, such as the remote server name, the shared folder name, and the local drive letter to be used for the mapping.

Example 1: Basic Usage

New-SmbMapping -LocalPath "Z:" -RemotePath "\servershare"

In this example, we are creating a new SMB mapping with the local drive letter Z: that points to the shared folder \servershare on the remote server.

Example 2: Using Credentials

$credential = Get-Credential
New-SmbMapping -LocalPath "Z:" -RemotePath "\servershare" -Credential $credential

In this example, we are using the Get-Credential cmdlet to prompt the user for credentials, which are then used to create the SMB mapping. This is useful when the remote server requires authentication.

Example 3: Persistent Mapping

New-SmbMapping -LocalPath "Z:" -RemotePath "\servershare" -Persistent $true

In this example, we are creating a persistent SMB mapping, which means that the mapping will be restored automatically after a system reboot. This is useful for mappings that need to be available at all times.

Managing SMB Mappings

Once you have created an SMB mapping using the New-SmbMapping command, you can manage it using other PowerShell commands. For example, you can use the Get-SmbMapping command to view all the current SMB mappings on the local computer, or the Remove-SmbMapping command to remove an existing mapping.

Example 4: Viewing SMB Mappings

Get-SmbMapping

This command will display a list of all the current SMB mappings on the local computer, including the local drive letter, the remote path, and the status of the mapping.

Example 5: Removing SMB Mappings

Remove-SmbMapping -LocalPath "Z:"

In this example, we are removing the SMB mapping with the local drive letter Z:. This will disconnect the mapping and remove it from the list of current mappings.

Conclusion

The New-SmbMapping command is a powerful tool for managing network shares in a Windows environment. By understanding how to use this command, system administrators can easily create and manage SMB mappings on the local computer. Whether you need to access shared folders on remote servers, or you need to create persistent mappings that are available at all times, the New-SmbMapping command has you covered.

If you’re looking for a reliable Hong Kong VPS hosting provider, look no further than Server.HK. With our Hong Kong VPS Hosting services, you can enjoy the benefits of a dedicated server at a fraction of the cost. Visit our website today to learn more about our VPS and cloud hosting solutions.

Recent Posts

  • How to Set a Static IP Address on a Debian Server: Theory and Best Practices
  • How to Manage Services with systemd on Debian: Theory and Best Practices
  • Debian Server Security Hardening: Best Practices and Core Theory
  • How to Monitor System Resources on a Debian Server: Theory and Best Practices
  • Debian Server Performance Tuning: Best Practices and Core Theory

Recent Comments

No comments to show.

Knowledge Base

Access detailed guides, tutorials, and resources.

Live Chat

Get instant help 24/7 from our support team.

Send Ticket

Our team typically responds within 10 minutes.

logo
Alipay Cc-paypal Cc-stripe Cc-visa Cc-mastercard Bitcoin
Cloud VPS
  • Hong Kong VPS
  • US VPS
Dedicated Servers
  • Hong Kong Servers
  • US Servers
  • Singapore Servers
  • Japan Servers
More
  • Contact Us
  • Blog
  • Legal
© 2026 Server.HK | Hosting Limited, Hong Kong | Company Registration No. 77008912
Telegram
Telegram @ServerHKBot