Can't input a path with spaces in it

Hey everyone, I’m having trouble with a script i’m building to get informations from active directory.

Here’s my code

{
#[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic') | Out-Null
Import-Module PowerShellAccessControl
#$Chemin = [Microsoft.VisualBasic.Interaction]::InputBox("entrer un chemin")
write-host " Z: (lettre de lecteur utilisée pour \\Aietes\Echange_RH) " -backgroundcolor black -foregroundcolor yellow
write-host " X: (lettre de lecteur utilisée pour \\Aietes\Echanges_Entreprises) " -backgroundcolor black -foregroundcolor yellow
write-host " W: (lettre de lecteur utilisée pour \\Aietes\Siege_Manpower) " -backgroundcolor black -foregroundcolor yellow
write-host "Entrez le chemin Ci dessous" -ForegroundColor Yellow
[string]$chemin = read-host
Get-AccessControlEntry $chemin|select-object principal, accessmask, info
write-host "--------------Le groupe est dans la colonne principal et les droits appliqué par ce dernier sous AccessMask--------------" -backgroundcolor black -foregroundcolor yellow
write-host " Merci de copié le nom du groupe désiré " -backgroundcolor black -foregroundcolor yellow
write-host " Accessmask donne les droits appliqué par ce groupe " -backgroundcolor black -foregroundcolor yellow
write-host " 2032127 = controle total, 1245631 = Lecture + écriture, 1179817= Lecture seulement " -backgroundcolor black -foregroundcolor yellow
write-host " entrer ici le nom du groupe désiré pour obtenir le gestionnaire: " -backgroundcolor black -foregroundcolor green
$group = read-host
get-adgroup $group -server *myserver* -properties *|select-object description,info |Format-Tablepause}

My problem is with the bold part, i need the user to enter a path bu some paths have space in them and it just doesn’t work with those.Sorry for the french parts in it but its just infos for the user.

The bold tag did not work but the problem is on line 9 and 10.

 

This is where the path is, how can i make it accept inputs with space?

Thanks.

You need double qoutes around your variable

Get-AccessControlEntry “$chemin”

Strange, it works with get-childitem:

PS C:\users\js> $a = read-host
hi there.txt
PS C:\users\js> get-childitem $a


    Directory: C:\users\js


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----        4/25/2019   1:53 PM             10 hi there.txt

If the string value in a variable contains spaces, wraping inside quotes are not required. Above Get-ChildItem example is expected to work.
Get-AccessControlEntry works with path which contains spaces as well. what is the exact error you are getting ?

Welp, turns out you’re right, kvprasoon. (I guess I’m conditioned to equate path space issues with double quoting lol) There must be another issue here, OP could you provide any error output you’re receiving?

Hey everyone thanks a lot for the answers you already provided.

I have a problem here, my powershell is in french and i haven’t figured out how to change it for now since i’m on a professional computer and i’m fairly new to powershell

Below you will find my error message that i translated myself.
Thanks a lot for the answer guys.

GetPathInformation : Type [Microsoft.Experimental.IO.LongPathDirectory] can't be found. make sure thats the assembly contening this type is loaded.
To the caracther C:\Users\8003108\Documents\WindowsPowerShell\Modules\PowerShellAccessControl\PowerShellAccessControl.psm1:1861 : 34
+ foreach ($ObjectInfo in (GetPathInformation @PSBoundParameters)) {
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,GetPathInformation 

Do i need a newer version of powershellaccesscontrol?

This is the name of the zip i installed for my powershell access control:

PowerShellAccessControl_3.0_20150413

Just as a side note: You don’t have to add another new post when you want to add information to a previous post - you can edit this previous post. :wink:

Seems like the dependecies are not met for the module. try installing it from NuGet Gallery | Microsoft.Experimental.IO 1.0.0

[quote quote=153581]Seems like the dependecies are not met for the module. try installing it from https://www.nuget.org/packages/Microsoft.Experimental.IO

[/quote]
Thanks for the link,i had some issues understanding since its my first time using a nupkg but its pretty straight forward

I tried it again with the experimental installed and it works!!!

Thanks a lot everyone this forum is perfect for newcomers =).

Below is the github repo for the module. You can download the whole module fresh from there.