Question
Move-item
- Jeulmi
- Auteur du sujet
- Hors Ligne
- Membre premium
-
Réduire
Plus d'informations
- Messages : 89
- Remerciements reçus 0
il y a 12 ans 10 mois #14878
par Jeulmi
Bonsoir,
J'essaye de déplacer un dossier d'utilisateur d'un groupe dans un autre groupe mais je n'y arrive pas :
[code:1]Set-location E:\eleves\
$SAM = 'EULMI'
$chemin = gci -recurse | where {$_.name -eq \"$SAM\"}
Move-item -path $chemin -destination E:\eleves\PI\[/code:1]
[code:1]$chemin
Répertoire : E:\eleves\AM
Mode LastWriteTime Length Name
----
----
d---- 20/05/2013 21:09 EULMI
[/code:1]
[code:1]Move-Item : Impossible de trouver le chemin d'accès « E:\eleves\EULMI », car il n'existe pas.
Au niveau de ligne : 4 Caractère : 10
+ Move-item <<<< -path $chemin -destination E:\eleves\PI\
+ CategoryInfo : ObjectNotFound: (E:\eleves\EULMI:«»String) [Move-Item], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.MoveItemCommand
[/code:1]
Comment je pourrai avoir un résultat du type \"E:\eleves\AM\EULMI\" ? (le répertoire AM est une classe, je ne peut pas le mettre en dur dans le script)
merci
<br><br>Message édité par: Beaussier, à: 20/05/13 21:58
J'essaye de déplacer un dossier d'utilisateur d'un groupe dans un autre groupe mais je n'y arrive pas :
[code:1]Set-location E:\eleves\
$SAM = 'EULMI'
$chemin = gci -recurse | where {$_.name -eq \"$SAM\"}
Move-item -path $chemin -destination E:\eleves\PI\[/code:1]
[code:1]$chemin
Répertoire : E:\eleves\AM
Mode LastWriteTime Length Name
----
----
d---- 20/05/2013 21:09 EULMI
[/code:1]
[code:1]Move-Item : Impossible de trouver le chemin d'accès « E:\eleves\EULMI », car il n'existe pas.
Au niveau de ligne : 4 Caractère : 10
+ Move-item <<<< -path $chemin -destination E:\eleves\PI\
+ CategoryInfo : ObjectNotFound: (E:\eleves\EULMI:«»String) [Move-Item], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.MoveItemCommand
[/code:1]
Comment je pourrai avoir un résultat du type \"E:\eleves\AM\EULMI\" ? (le répertoire AM est une classe, je ne peut pas le mettre en dur dans le script)
merci
Connexion ou Créer un compte pour participer à la conversation.
- Jeulmi
- Auteur du sujet
- Hors Ligne
- Membre premium
-
Réduire
Plus d'informations
- Messages : 89
- Remerciements reçus 0
il y a 12 ans 10 mois #14879
par Jeulmi
Réponse de Jeulmi sur le sujet Re:Move-item
Bon bah j'ai trouvé 
[code:1]
Set-location E:\eleves\
$SAM = 'EULMI'
gci -recurse | where {$_.name -eq \"$SAM\"} | Move-item -destination E:\eleves\PI[/code:1]
C'est fou dés que je poste, je trouve la réponse peu de temps après
[code:1]
Set-location E:\eleves\
$SAM = 'EULMI'
gci -recurse | where {$_.name -eq \"$SAM\"} | Move-item -destination E:\eleves\PI[/code:1]
C'est fou dés que je poste, je trouve la réponse peu de temps après
Connexion ou Créer un compte pour participer à la conversation.
- Charly
- Hors Ligne
- Nouveau membre
-
Réduire
Plus d'informations
- Messages : 17
- Remerciements reçus 0
il y a 12 ans 10 mois #14880
par Charly
Réponse de Charly sur le sujet Re:Move-item
Hello !
Je pense que c'est parce que ta variable $chemin est de type System.IO.DirectoryInfo
[code:1]PS C:\> $test | gm
TypeName: System.IO.DirectoryInfo
Name MemberType Definition
----
Mode CodeProperty System.String Mode{get=Mode;}
Create Method System.Void Create(System.Security.AccessControl.DirectorySecurity director...
CreateObjRef Method System.Runtime.Remoting.ObjRef CreateObjRef(type requestedType)
CreateSubdirectory Method System.IO.DirectoryInfo CreateSubdirectory(string path), System.IO.Director...
Delete Method System.Void Delete(), System.Void Delete(bool recursive)
Equals Method bool Equals(System.Object obj)
GetAccessControl Method System.Security.AccessControl.DirectorySecurity GetAccessControl(), System....
GetDirectories Method System.IO.DirectoryInfo[] GetDirectories(), System.IO.DirectoryInfo[] GetDi...
GetFiles Method System.IO.FileInfo[] GetFiles(), System.IO.FileInfo[] GetFiles(string searc...
GetFileSystemInfos Method System.IO.FileSystemInfo[] GetFileSystemInfos(string searchPattern), System...
GetHashCode Method int GetHashCode()
GetLifetimeService Method System.Object GetLifetimeService()
GetObjectData Method System.Void GetObjectData(System.Runtime.Serialization.SerializationInfo in...
GetType Method type GetType()
InitializeLifetimeService Method System.Object InitializeLifetimeService()
MoveTo Method System.Void MoveTo(string destDirName)
Refresh Method System.Void Refresh()
SetAccessControl Method System.Void SetAccessControl(System.Security.AccessControl.DirectorySecurit...
ToString Method string ToString()
PSChildName NoteProperty System.String PSChildName=Anniversaire_2ans_Anais
PSDrive NoteProperty System.Management.Automation.PSDriveInfo PSDrive=C
PSIsContainer NoteProperty System.Boolean PSIsContainer=True
PSParentPath NoteProperty System.String PSParentPath=Microsoft.PowerShell.Core\FileSystem::C:\Photos
PSPath NoteProperty System.String PSPath=Microsoft.PowerShell.Core\FileSystem::C:\Photos\Annive...
PSProvider NoteProperty System.Management.Automation.ProviderInfo PSProvider=Microsoft.PowerShell.C...
Attributes Property System.IO.FileAttributes Attributes {get;set;}
CreationTime Property System.DateTime CreationTime {get;set;}
CreationTimeUtc Property System.DateTime CreationTimeUtc {get;set;}
Exists Property System.Boolean Exists {get;}
Extension Property System.String Extension {get;}
FullName Property System.String FullName {get;}
LastAccessTime Property System.DateTime LastAccessTime {get;set;}
LastAccessTimeUtc Property System.DateTime LastAccessTimeUtc {get;set;}
LastWriteTime Property System.DateTime LastWriteTime {get;set;}
LastWriteTimeUtc Property System.DateTime LastWriteTimeUtc {get;set;}
Name Property System.String Name {get;}
Parent Property System.IO.DirectoryInfo Parent {get;}
Root Property System.IO.DirectoryInfo Root {get;}
BaseName ScriptProperty System.Object BaseName {get=$this.Name;}[/code:1]
La cmdlet MOVE-ITEM attend un Path et pas ce que lui renvoi $chemin.
Il faudrait que tu boucles :
[code:1]
foreach ($i in $chemin)
{
Move-Item -Path $i.FullName -Destination $Par_la
}
[/code:1]
A+
Je pense que c'est parce que ta variable $chemin est de type System.IO.DirectoryInfo
[code:1]PS C:\> $test | gm
TypeName: System.IO.DirectoryInfo
Name MemberType Definition
----
Mode CodeProperty System.String Mode{get=Mode;}
Create Method System.Void Create(System.Security.AccessControl.DirectorySecurity director...
CreateObjRef Method System.Runtime.Remoting.ObjRef CreateObjRef(type requestedType)
CreateSubdirectory Method System.IO.DirectoryInfo CreateSubdirectory(string path), System.IO.Director...
Delete Method System.Void Delete(), System.Void Delete(bool recursive)
Equals Method bool Equals(System.Object obj)
GetAccessControl Method System.Security.AccessControl.DirectorySecurity GetAccessControl(), System....
GetDirectories Method System.IO.DirectoryInfo[] GetDirectories(), System.IO.DirectoryInfo[] GetDi...
GetFiles Method System.IO.FileInfo[] GetFiles(), System.IO.FileInfo[] GetFiles(string searc...
GetFileSystemInfos Method System.IO.FileSystemInfo[] GetFileSystemInfos(string searchPattern), System...
GetHashCode Method int GetHashCode()
GetLifetimeService Method System.Object GetLifetimeService()
GetObjectData Method System.Void GetObjectData(System.Runtime.Serialization.SerializationInfo in...
GetType Method type GetType()
InitializeLifetimeService Method System.Object InitializeLifetimeService()
MoveTo Method System.Void MoveTo(string destDirName)
Refresh Method System.Void Refresh()
SetAccessControl Method System.Void SetAccessControl(System.Security.AccessControl.DirectorySecurit...
ToString Method string ToString()
PSChildName NoteProperty System.String PSChildName=Anniversaire_2ans_Anais
PSDrive NoteProperty System.Management.Automation.PSDriveInfo PSDrive=C
PSIsContainer NoteProperty System.Boolean PSIsContainer=True
PSParentPath NoteProperty System.String PSParentPath=Microsoft.PowerShell.Core\FileSystem::C:\Photos
PSPath NoteProperty System.String PSPath=Microsoft.PowerShell.Core\FileSystem::C:\Photos\Annive...
PSProvider NoteProperty System.Management.Automation.ProviderInfo PSProvider=Microsoft.PowerShell.C...
Attributes Property System.IO.FileAttributes Attributes {get;set;}
CreationTime Property System.DateTime CreationTime {get;set;}
CreationTimeUtc Property System.DateTime CreationTimeUtc {get;set;}
Exists Property System.Boolean Exists {get;}
Extension Property System.String Extension {get;}
FullName Property System.String FullName {get;}
LastAccessTime Property System.DateTime LastAccessTime {get;set;}
LastAccessTimeUtc Property System.DateTime LastAccessTimeUtc {get;set;}
LastWriteTime Property System.DateTime LastWriteTime {get;set;}
LastWriteTimeUtc Property System.DateTime LastWriteTimeUtc {get;set;}
Name Property System.String Name {get;}
Parent Property System.IO.DirectoryInfo Parent {get;}
Root Property System.IO.DirectoryInfo Root {get;}
BaseName ScriptProperty System.Object BaseName {get=$this.Name;}[/code:1]
La cmdlet MOVE-ITEM attend un Path et pas ce que lui renvoi $chemin.
Il faudrait que tu boucles :
[code:1]
foreach ($i in $chemin)
{
Move-Item -Path $i.FullName -Destination $Par_la
}
[/code:1]
A+
Connexion ou Créer un compte pour participer à la conversation.
Temps de génération de la page : 0.058 secondes
- Vous êtes ici :
-
Accueil
-
forum
-
PowerShell
-
Entraide pour les débutants
- Move-item