Software⏱️ 3 min read📅 2026-06-11

How to Fix: Powershell throw error on deleting a directory

Error fixing powershell delete directory issue.

Quick Answer: The issue is caused by the use of a relative path in the command. Use absolute paths or quotes to fix the error.

The error 'A positional parameter cannot be found that accepts argument '. ajkamal.' occurs when trying to delete a directory using the `rmdir` command. This issue affects users who are attempting to remove directories without fully understanding the path specifications.

This error can be frustrating because it prevents users from successfully deleting files and directories, leading to cluttered file systems and potential security risks.

🔍 Why This Happens

  • The primary reason for this error is that the `rmdir` command requires a full path to the directory to be deleted. When a relative path is used (in this case, '. ajkamal'), PowerShell cannot determine the correct location of the directory.
  • An alternative cause could be if the directory name contains special characters or spaces, which may not be properly escaped when using the `rmdir` command.

✅ Best Solutions to Fix It

Using Absolute Paths

  1. Step 1: To fix this issue, use the absolute path to the directory you want to delete. This can be done by navigating to the parent directory containing the target folder and then using the `rmdir` command with the full path.
  2. Step 2: For example, if the directory is located in 'C:\Users\username\Documents', navigate to this location and use the following command: rmdir C:\
  3. Step 3: Alternatively, you can also use the `Get-Location` cmdlet to get the current working directory and then append the full path to the target directory.

Escaping Special Characters

  1. Step 1: If the directory name contains special characters or spaces, try escaping them by surrounding the name with double quotes. For example: rmdir "C:\\Users\\username\\Documents\\rajkamal".
  2. Step 2: Note that this method may not work if the directory name is very long or contains complex path specifications.

✨ Wrapping Up

By following these steps, you should be able to successfully delete a directory using the `rmdir` command. Remember to always use absolute paths and consider escaping special characters when working with file names.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions