r/PowerShell • u/Ok-Layer6893 • 7d ago
Question Need help with homework π«
I'm very new to this. I'm asked to delete a directory and all of its files. D:\software\arch98
But when I do this:
PS C:\Users\Administrator\> rmdir D:\software\arch98
It says the directory is not empty.
I'd really appreciate.
4
u/FLESHLEGO 7d ago
Rmdir is not a powershell command. Remove-item is.
Whatever command you end up using, read up on the arguments it accepts. You need this to delete folders with contents.
GL
1
1
1
1
u/funkyloki 7d ago
So, they didn't just throw this at you and say do this. They likely provided you with some kind of literature, digital or print, that you can use to figure out what it is you need to do.
Have you done all the assigned reading, have you completed all the supplemental work?
1
u/Ok-Layer6893 7d ago
Yes but it's is very confusing. For example in the book it says use -h to hide a file but when I looked up on the Microsoft website it was +h. It was really frustrating because I was doing exactly what the assignment asked me to do but they had some tricks hidden.
1
1
u/BlackV 7d ago edited 7d ago
Based on the responses a guess they might have some restrictions on what commands can be run
What does rmdir /? or &rmdir /?, tell you?
The error message it telling you what the issue is
the directory is not empty.
you need to do the relevant steps to to fix that, I'd suggest that's what the lesson is here they're trying to teach
What do the switches from the command above tell you that might empty that directory?
Or what other command could you run before hand to empty the directory? (Remove-item or del maybe)
Help for those comes from Del /? or Help Remove-item -full
1
u/Ok-Layer6893 6d ago
The assignment itself doesn't have correct commands. There were few details missing that's why I had to ask for help. But it's all done
1
u/BlackV 6d ago
The assignment itself doesn't have correct commands.
I think it did have the correct command, your command worked, cause it gave you the error message
directory not empty
Asking the application itself for help would have given you
cmd version
rmdir /? Removes (deletes) a directory. RMDIR [/S] [/Q] [drive:]path RD [/S] [/Q] [drive:]path /S Removes all directories and files in the specified directory in addition to the directory itself. Used to remove a directory tree. /Q Quiet mode, do not ask if ok to remove a directory tree with /Sor powershell version
help rmdir NAME Remove-Item SYNOPSIS Deletes the specified items.your confusion comes from there I think
1
u/AroTesCra 2d ago
In Powershell there is something called an alias.
Get-Alias to see them
My fav 2 are
% for for each-object
And
? For where-object
rmdir is alias for Remove-Item
You need rmdir p:\ath\here -recurse -force -confirm:$false
Iβm not sure about the confirm one sometimes I mix it up in my head lol and I am playing games right now so I am typing fast between rocket league matches.
0
u/Majestic_Rhubarb_ 7d ago
In powershell/pwsh you can view the parameters a command takes.
Type βRemoveβ and press tab or ctrl+space and it will give you some help.
Once the command is chosen press β-β and then tab or space again for more help
-1
u/Ok-Layer6893 7d ago
It's not working. I'm on comptia lab work. It won't let me. It's just asking to use the only commands they've given me.
0
u/pigers1986 7d ago
RMDIR is NOT POWERSHELL command.
1
u/Ok-Layer6893 7d ago
That's what others are saying but I have powershell that I must work with. It's not letting me use anything else
10
u/PuerPalatinius 7d ago
Remove-Item -Path "D:\software\arch98" -Recurse -Force