I would like to execute a program.exe which resides next to the script.ps1 file...
How can i get this location/folder?
(this is not a fixed location/folder, can be a usb stick or network drive etc)
I have tried to use
$MyInvocation.MyCommand.Path
But it seems not to be helping me (or i'm not using it the rigth way)
Thanks
This is the pattern I normally use:
$exeName = "MyApplication.exe"
$scriptFolder = Split-Path -Parent $MyInvocation.MyCommand.Path
$exeFullPath = Join-Path -Path $scriptFolder -ChildPath $exeName
$MyInvocation is an automatic variable.
Contains an information about the current command, such as the name,
parameters, parameter values, and information about how the command
was started, called, or "invoked," such as the name of the script that
called the current command.
Note that the object returned by $MyInvocation.MyCommand is different depending upon the context from which it was executed.
The type ScriptInfo is returned from the powershell command window, notice the lack of Path property:
TypeName: System.Management.Automation.ScriptInfo
Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
CommandType Property System.Management.Automation.CommandTypes CommandType {get;}
Definition Property System.String Definition {get;}
Module Property System.Management.Automation.PSModuleInfo Module {get;}
ModuleName Property System.String ModuleName {get;}
Name Property System.String Name {get;}
OutputType Property System.Collections.ObjectModel.ReadOnlyCollection`1[[System.Management.Automation.PSTyp...
Parameters Property System.Collections.Generic.Dictionary`2[[System.String, mscorlib, Version=2.0.0.0, Cult...
ParameterSets Property System.Collections.ObjectModel.ReadOnlyCollection`1[[System.Management.Automation.Comma...
ScriptBlock Property System.Management.Automation.ScriptBlock ScriptBlock {get;}
Visibility Property System.Management.Automation.SessionStateEntryVisibility Visibility {get;set;}
HelpUri ScriptProperty System.Object HelpUri {get=try...
Whereas the type is ExternalScriptInfo when run from a script, notice the additional properties ScriptContents and Path etc.
TypeName: System.Management.Automation.ExternalScriptInfo
Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
CommandType Property System.Management.Automation.CommandTypes CommandType {get;}
Definition Property System.String Definition {get;}
Module Property System.Management.Automation.PSModuleInfo Module {get;}
ModuleName Property System.String ModuleName {get;}
Name Property System.String Name {get;}
OriginalEncoding Property System.Text.Encoding OriginalEncoding {get;}
OutputType Property System.Collections.ObjectModel.ReadOnlyCollection`1[[System.Management.Automation.PS...
Parameters Property System.Collections.Generic.Dictionary`2[[System.String, mscorlib, Version=2.0.0.0, C...
ParameterSets Property System.Collections.ObjectModel.ReadOnlyCollection`1[[System.Management.Automation.Co...
Path Property System.String Path {get;}
ScriptBlock Property System.Management.Automation.ScriptBlock ScriptBlock {get;}
ScriptContents Property System.String ScriptContents {get;}
Visibility Property System.Management.Automation.SessionStateEntryVisibility Visibility {get;set;}
HelpUri ScriptProperty System.Object HelpUri {get=try...
Related
How can I get a list possible values of cmdlet parameter programmatically?
E.g for New-Item -Type:
File
Directory
SymbolicLink
Junction
HardLink
Get-Help New-Item -Full
Get-Command New-Item | select *
You can also check the online documentation (e.g. New-Item).
Or you can use
(Get-Command -Name new-item).parametersets
as suggested by vonPryz above.
For "Get-" cmdlets I usually create an object and then do a Get-Member to retrieve the definition of the members.
e.g.
$item = Get-Item .\test.csv
$item | Get-Member
TypeName: System.IO.FileInfo
Name MemberType Definition
---- ---------- ----------
LinkType CodeProperty System.String LinkType{get=GetLinkType;}
Mode CodeProperty System.String Mode{get=Mode;}
Target CodeProperty System.Collections.Generic.IEnumerable`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] Target{get=GetTarget;}
AppendText Method System.IO.StreamWriter AppendText()
CopyTo Method System.IO.FileInfo CopyTo(string destFileName), System.IO.FileInfo CopyTo(string destFileName, bool overwrite)
Create Method System.IO.FileStream Create()
CreateObjRef Method System.Runtime.Remoting.ObjRef CreateObjRef(type requestedType)
CreateText Method System.IO.StreamWriter CreateText()
Decrypt Method void Decrypt()
Delete Method void Delete()
Encrypt Method void Encrypt()
Equals Method bool Equals(System.Object obj)
GetAccessControl Method System.Security.AccessControl.FileSecurity GetAccessControl(), System.Security.AccessControl.FileSecurity GetAccessControl(System.Security.AccessControl.AccessControlSections includeSections)
GetHashCode Method int GetHashCode()
GetLifetimeService Method System.Object GetLifetimeService()
GetObjectData Method void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context), void ISerializable.GetObjectData(System.Runtime.Serialization.Se...
GetType Method type GetType()
InitializeLifetimeService Method System.Object InitializeLifetimeService()
MoveTo Method void MoveTo(string destFileName)
Open Method System.IO.FileStream Open(System.IO.FileMode mode), System.IO.FileStream Open(System.IO.FileMode mode, System.IO.FileAccess access), System.IO.FileStream Open(System.IO.FileMode mode, System.I...
OpenRead Method System.IO.FileStream OpenRead()
OpenText Method System.IO.StreamReader OpenText()
OpenWrite Method System.IO.FileStream OpenWrite()
Refresh Method void Refresh()
Replace Method System.IO.FileInfo Replace(string destinationFileName, string destinationBackupFileName), System.IO.FileInfo Replace(string destinationFileName, string destinationBackupFileName, bool ignoreMe...
SetAccessControl Method void SetAccessControl(System.Security.AccessControl.FileSecurity fileSecurity)
ToString Method string ToString()
PSChildName NoteProperty string PSChildName=test.csv
PSDrive NoteProperty PSDriveInfo PSDrive=C
PSIsContainer NoteProperty bool PSIsContainer=False
PSParentPath NoteProperty string PSParentPath=Microsoft.PowerShell.Core\FileSystem::C:\test
PSPath NoteProperty string PSPath=Microsoft.PowerShell.Core\FileSystem::C:\test\test.csv
PSProvider NoteProperty ProviderInfo PSProvider=Microsoft.PowerShell.Core\FileSystem
Attributes Property System.IO.FileAttributes Attributes {get;set;}
CreationTime Property datetime CreationTime {get;set;}
CreationTimeUtc Property datetime CreationTimeUtc {get;set;}
Directory Property System.IO.DirectoryInfo Directory {get;}
DirectoryName Property string DirectoryName {get;}
Exists Property bool Exists {get;}
Extension Property string Extension {get;}
FullName Property string FullName {get;}
IsReadOnly Property bool IsReadOnly {get;set;}
LastAccessTime Property datetime LastAccessTime {get;set;}
LastAccessTimeUtc Property datetime LastAccessTimeUtc {get;set;}
LastWriteTime Property datetime LastWriteTime {get;set;}
LastWriteTimeUtc Property datetime LastWriteTimeUtc {get;set;}
Length Property long Length {get;}
Name Property string Name {get;}
BaseName ScriptProperty System.Object BaseName {get=if ($this.Extension.Length -gt 0){$this.Name.Remove($this.Name.Length - $this.Extension.Length)}else{$this.Name};}
VersionInfo ScriptProperty System.Object VersionInfo {get=[System.Diagnostics.FileVersionInfo]::GetVersionInfo($this.FullName);}
The code below shows the users with licenses but I need to know what their sync type is as well and I am unsure how to get that information
# Connect to o365 tenant
Connect-MsolService
# Get all users in o365 and get license information
$groupOfUsers = Get-MsolUser -all
$results = foreach ($user in $groupOfUsers) {
$licenses = $user.licenses.accountskuid
foreach ($license in $licenses) {
[pscustomobject]#{
UPN = $user.userprincipalname
License = $license
}
}
}
# Export the results to csv
$results | Export-Csv c:\scripts\UsersWitho365licenses.csv -NoTypeInformation
Everything in Powershell is an object, therefore, it has methods and properties, and as LotPings commented,
Get-MsolUser | Get-Member
But this is an array which may differ on the properties an methods you will be able to use in the foreach. Try this (I will do it with FileItems as I don't have that module):
cd $HOME
$files = Get-ChildItem
$files | Get-Member
Result:
TypeName: System.IO.DirectoryInfo
Name MemberType Definition
---- ---------- ----------
LinkType CodeProperty System.String LinkType{get=GetLinkType;}
Mode CodeProperty System.String Mode{get=Mode;}
Target CodeProperty System.Collections.Generic.IEnumerable`1[[System.String, mscorlib, Version=4.0.0...
Create Method void Create(), void Create(System.Security.AccessControl.DirectorySecurity direc...
CreateObjRef Method System.Runtime.Remoting.ObjRef CreateObjRef(type requestedType)
CreateSubdirectory Method System.IO.DirectoryInfo CreateSubdirectory(string path), System.IO.DirectoryInfo...
Delete Method void Delete(), void Delete(bool recursive)
EnumerateDirectories Method System.Collections.Generic.IEnumerable[System.IO.DirectoryInfo] EnumerateDirecto...
EnumerateFiles Method System.Collections.Generic.IEnumerable[System.IO.FileInfo] EnumerateFiles(), Sys...
EnumerateFileSystemInfos Method System.Collections.Generic.IEnumerable[System.IO.FileSystemInfo] EnumerateFileSy...
Equals Method bool Equals(System.Object obj)
GetAccessControl Method System.Security.AccessControl.DirectorySecurity GetAccessControl(), System.Secur...
GetDirectories Method System.IO.DirectoryInfo[] GetDirectories(), System.IO.DirectoryInfo[] GetDirecto...
GetFiles Method System.IO.FileInfo[] GetFiles(string searchPattern), System.IO.FileInfo[] GetFil...
GetFileSystemInfos Method System.IO.FileSystemInfo[] GetFileSystemInfos(string searchPattern), System.IO.F...
GetHashCode Method int GetHashCode()
GetLifetimeService Method System.Object GetLifetimeService()
GetObjectData Method void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.R...
GetType Method type GetType()
InitializeLifetimeService Method System.Object InitializeLifetimeService()
MoveTo Method void MoveTo(string destDirName)
Refresh Method void Refresh()
SetAccessControl Method void SetAccessControl(System.Security.AccessControl.DirectorySecurity directoryS...
ToString Method string ToString()
PSChildName NoteProperty string PSChildName=.dotnet
PSDrive NoteProperty PSDriveInfo PSDrive=C
PSIsContainer NoteProperty bool PSIsContainer=True
PSParentPath NoteProperty string PSParentPath=Microsoft.PowerShell.Core\FileSystem::C:\Users\Ras_T
PSPath NoteProperty string PSPath=Microsoft.PowerShell.Core\FileSystem::C:\Users\Ras_T\.dotnet
PSProvider NoteProperty ProviderInfo PSProvider=Microsoft.PowerShell.Core\FileSystem
Attributes Property System.IO.FileAttributes Attributes {get;set;}
CreationTime Property datetime CreationTime {get;set;}
CreationTimeUtc Property datetime CreationTimeUtc {get;set;}
Exists Property bool Exists {get;}
Extension Property string Extension {get;}
FullName Property string FullName {get;}
LastAccessTime Property datetime LastAccessTime {get;set;}
LastAccessTimeUtc Property datetime LastAccessTimeUtc {get;set;}
LastWriteTime Property datetime LastWriteTime {get;set;}
LastWriteTimeUtc Property datetime LastWriteTimeUtc {get;set;}
Name Property 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;}
TypeName: System.IO.FileInfo
Name MemberType Definition
---- ---------- ----------
LinkType CodeProperty System.String LinkType{get=GetLinkType;}
Mode CodeProperty System.String Mode{get=Mode;}
Target CodeProperty System.Collections.Generic.IEnumerable`1[[System.String, mscorlib, Version=4.0.0...
AppendText Method System.IO.StreamWriter AppendText()
CopyTo Method System.IO.FileInfo CopyTo(string destFileName), System.IO.FileInfo CopyTo(string...
Create Method System.IO.FileStream Create()
CreateObjRef Method System.Runtime.Remoting.ObjRef CreateObjRef(type requestedType)
CreateText Method System.IO.StreamWriter CreateText()
Decrypt Method void Decrypt()
Delete Method void Delete()
Encrypt Method void Encrypt()
Equals Method bool Equals(System.Object obj)
GetAccessControl Method System.Security.AccessControl.FileSecurity GetAccessControl(), System.Security.A...
GetHashCode Method int GetHashCode()
GetLifetimeService Method System.Object GetLifetimeService()
GetObjectData Method void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.R...
GetType Method type GetType()
InitializeLifetimeService Method System.Object InitializeLifetimeService()
MoveTo Method void MoveTo(string destFileName)
Open Method System.IO.FileStream Open(System.IO.FileMode mode), System.IO.FileStream Open(Sy...
OpenRead Method System.IO.FileStream OpenRead()
OpenText Method System.IO.StreamReader OpenText()
OpenWrite Method System.IO.FileStream OpenWrite()
Refresh Method void Refresh()
Replace Method System.IO.FileInfo Replace(string destinationFileName, string destinationBackupF...
SetAccessControl Method void SetAccessControl(System.Security.AccessControl.FileSecurity fileSecurity)
ToString Method string ToString()
PSChildName NoteProperty string PSChildName=.bash_history
PSDrive NoteProperty PSDriveInfo PSDrive=C
PSIsContainer NoteProperty bool PSIsContainer=False
PSParentPath NoteProperty string PSParentPath=Microsoft.PowerShell.Core\FileSystem::C:\Users\Ras_T
PSPath NoteProperty string PSPath=Microsoft.PowerShell.Core\FileSystem::C:\Users\Ras_T\.bash_history
PSProvider NoteProperty ProviderInfo PSProvider=Microsoft.PowerShell.Core\FileSystem
Attributes Property System.IO.FileAttributes Attributes {get;set;}
CreationTime Property datetime CreationTime {get;set;}
CreationTimeUtc Property datetime CreationTimeUtc {get;set;}
Directory Property System.IO.DirectoryInfo Directory {get;}
DirectoryName Property string DirectoryName {get;}
Exists Property bool Exists {get;}
Extension Property string Extension {get;}
FullName Property string FullName {get;}
IsReadOnly Property bool IsReadOnly {get;set;}
LastAccessTime Property datetime LastAccessTime {get;set;}
LastAccessTimeUtc Property datetime LastAccessTimeUtc {get;set;}
LastWriteTime Property datetime LastWriteTime {get;set;}
LastWriteTimeUtc Property datetime LastWriteTimeUtc {get;set;}
Length Property long Length {get;}
Name Property string Name {get;}
BaseName ScriptProperty System.Object BaseName {get=if ($this.Extension.Length -gt 0){$this.Name.Remove(...
VersionInfo ScriptProperty System.Object VersionInfo {get=[System.Diagnostics.FileVersionInfo]::GetVersionI...
But You don't care about all that you just want the properties, you can get them like this:
$fileItem = $files[0]
$fileItem | Get-Member -
Result:
TypeName: System.IO.DirectoryInfo
Name MemberType Definition
---- ---------- ----------
LinkType CodeProperty System.String LinkType{get=GetLinkType;}
Mode CodeProperty System.String Mode{get=Mode;}
Target CodeProperty System.Collections.Generic.IEnumerable`1[[System.String, mscorlib, Version=4.0.0.0, Cult...
PSChildName NoteProperty string PSChildName=.dotnet
PSDrive NoteProperty PSDriveInfo PSDrive=C
PSIsContainer NoteProperty bool PSIsContainer=True
PSParentPath NoteProperty string PSParentPath=Microsoft.PowerShell.Core\FileSystem::C:\Users\Ras_T
PSPath NoteProperty string PSPath=Microsoft.PowerShell.Core\FileSystem::C:\Users\Ras_T\.dotnet
PSProvider NoteProperty ProviderInfo PSProvider=Microsoft.PowerShell.Core\FileSystem
Attributes Property System.IO.FileAttributes Attributes {get;set;}
CreationTime Property datetime CreationTime {get;set;}
CreationTimeUtc Property datetime CreationTimeUtc {get;set;}
Exists Property bool Exists {get;}
Extension Property string Extension {get;}
FullName Property string FullName {get;}
LastAccessTime Property datetime LastAccessTime {get;set;}
LastAccessTimeUtc Property datetime LastAccessTimeUtc {get;set;}
LastWriteTime Property datetime LastWriteTime {get;set;}
LastWriteTimeUtc Property datetime LastWriteTimeUtc {get;set;}
Name Property 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;}
One of the properties in the output of Get-Member should be what you are looking for.
I'm trying to update/add some RC information in DLL directly from the Powershell.
I have found how I can get it but I didn't found how set some field like SpecialBuild or PrivateBuild.
PS C:\> (gi .\mydll.dll).VersionInfo | fl
OriginalFilename : mydll.dll
FileDescription : mydll.dll
...............................
PrivateBuild : 32572
SpecialBuild : NOT_HOTFIX
FileVersionRaw : 17.3.0.12013
ProductVersionRaw : 17.3.0.12013
PS C:\> (gi .\mydll.dll).VersionInfo | gm
TypeName : System.Diagnostics.FileVersionInfo
Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
Comments Property string Comments {get;}
.................................................
PrivateBuild Property string PrivateBuild {get;}
ProductBuildPart Property int ProductBuildPart {get;}
ProductMajorPart Property int ProductMajorPart {get;}
ProductMinorPart Property int ProductMinorPart {get;}
ProductName Property string ProductName {get;}
ProductPrivatePart Property int ProductPrivatePart {get;}
ProductVersion Property string ProductVersion {get;}
SpecialBuild Property string SpecialBuild {get;}
FileVersionRaw ScriptProperty System.Object FileVersionRaw {get=New-Object System.Version -ArgumentList #(...
ProductVersionRaw ScriptProperty System.Object ProductVersionRaw {get=New-Object System.Version -ArgumentList #(...
As you can see, properties are get only here.
So do you know how I can update theses fields ?
Thanks in advance for your help ;)
Update fields possible with a tool like Resource Hacker, or verpatch, but it's not recommended. If the dll is yours, it's much easier to update it before compilation.
One of the downsides of patching compiled dll is that if it's signed, the signature will no longer be valid. Also, sometimes patching may result in a corrupted dll.
Is there any particular reason why you want to change it after compilation?
this will sound like a bad joke, but apparently geniuses from MS arent capable of making uber complicated -exclude gci parameter work. By "genious" design it only works on files, not on entire path. So how to make it work.
For example how to exclude all files whose path contains "Windows" substring?
naive
gci -exclude "*Windows*" -rec
doesnt work
EDIT: googled/figured out this:
| where {$_.DirectoryName -notmatch ".*abcdef.*" }
If somebody knows better solution please share. If not will close question.
The solution is this:
gci ./ |Where{ $_.PSPath -notmatch ".*Windows.*"}
BTW useful thing for guessing solutions to problems like this is to know what methods the current object has, for that I used Get-Member. Example output:
PS C:\Users\jh> gci ./ | Get-Member
TypeName: System.IO.DirectoryInfo
Name MemberType Definition
---- ---------- ----------
Mode CodeProperty System.String Mode{get=Mode;}
Create Method void Create(), void Create(System.Security.AccessControl.DirectorySecurity ...
CreateObjRef Method System.Runtime.Remoting.ObjRef CreateObjRef(type requestedType)
CreateSubdirectory Method System.IO.DirectoryInfo CreateSubdirectory(string path), System.IO.Director...
Delete Method void Delete(), void Delete(bool recursive)
EnumerateDirectories Method System.Collections.Generic.IEnumerable[System.IO.DirectoryInfo] EnumerateDi...
EnumerateFiles Method System.Collections.Generic.IEnumerable[System.IO.FileInfo] EnumerateFiles()...
EnumerateFileSystemInfos Method System.Collections.Generic.IEnumerable[System.IO.FileSystemInfo] EnumerateF...
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(string searchPattern), System.IO.FileInfo[] G...
GetFileSystemInfos Method System.IO.FileSystemInfo[] GetFileSystemInfos(string searchPattern), System...
GetHashCode Method int GetHashCode()
GetLifetimeService Method System.Object GetLifetimeService()
GetObjectData Method void GetObjectData(System.Runtime.Serialization.SerializationInfo info, Sys...
GetType Method type GetType()
InitializeLifetimeService Method System.Object InitializeLifetimeService()
MoveTo Method void MoveTo(string destDirName)
Refresh Method void Refresh()
SetAccessControl Method void SetAccessControl(System.Security.AccessControl.DirectorySecurity direc...
ToString Method string ToString()
PSChildName NoteProperty System.String PSChildName=Contacts
PSDrive NoteProperty System.Management.Automation.PSDriveInfo PSDrive=C
PSIsContainer NoteProperty System.Boolean PSIsContainer=True
PSParentPath NoteProperty System.String PSParentPath=Microsoft.PowerShell.Core\FileSystem::C:\Users\jh
PSPath NoteProperty System.String PSPath=Microsoft.PowerShell.Core\FileSystem::C:\Users\jh\Cont...
PSProvider NoteProperty System.Management.Automation.ProviderInfo PSProvider=Microsoft.PowerShell.C...
Attributes Property System.IO.FileAttributes Attributes {get;set;}
CreationTime Property datetime CreationTime {get;set;}
CreationTimeUtc Property datetime CreationTimeUtc {get;set;}
Exists Property bool Exists {get;}
Extension Property string Extension {get;}
FullName Property string FullName {get;}
LastAccessTime Property datetime LastAccessTime {get;set;}
LastAccessTimeUtc Property datetime LastAccessTimeUtc {get;set;}
LastWriteTime Property datetime LastWriteTime {get;set;}
LastWriteTimeUtc Property datetime LastWriteTimeUtc {get;set;}
Name Property 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;}
How do I pipeline the output of Exchange 2010's Get-MoveRequest command so that the Name variable can be used in the $Username variable below?
[CmdletBinding(DefaultParameterSetName = "MoveUser")]
param(
[Parameter(Mandatory = $true, ParameterSetName = "MoveUser", ValueFromPipeline = $true, Position = 0)]
$Username
)
function Get-MBStats($Username )
{
$req = Get-MailboxStatistics -Identity $Username -IncludeMoveHistory
$UserDetail = ($req).MoveHistory[0]
# TODO: SOME CUSTOM STUFF HERE #
New-Object PSObject -Property #{
Username = $Username
Status = $UserDetail.Status
TargetDatabase = $UserDetail.TargetDatabase
CompletionTime = $UserDetail.CompletionTimestamp
MailboxSizeKB = $UserDetail.TotalMailboxSize.ToKB()
DurationSec = $UserDetail.TotalInProgressDuration.TotalSeconds
BadItems = $UserDetail.BadItemsEncountered
}
# Todo: GUI http://msdn.microsoft.com/en-us/magazine/hh288074.aspx #
}
Get-MBStats($Username)
UPDATE
Here are the members output from MoveRequest (source)
TypeName: Microsoft.Exchange.Management.RecipientTasks.MoveRequest
Name MemberType Definition
---- ---------- ----------
Clone Method System.Object Clone()
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetProperties Method System.Object[] GetProperties(System.Collections.Generic.ICollection[Microso...
GetType Method type GetType()
ToString Method string ToString()
Validate Method Microsoft.Exchange.Data.ValidationError[] Validate()
PSComputerName NoteProperty System.String PSComputerName=nycexhc01.nfp.com
RunspaceId NoteProperty System.Guid RunspaceId=dc444c7e-bcac-4c1c-8fdf-847875456c03
Alias Property System.String Alias {get;set;}
BatchName Property System.String BatchName {get;}
Direction Property Microsoft.Exchange.MailboxReplicationService.RequestDirection Direction {get;}
DisplayName Property System.String DisplayName {get;set;}
DistinguishedName Property System.String DistinguishedName {get;}
ExchangeGuid Property System.Guid ExchangeGuid {get;}
ExchangeVersion Property Microsoft.Exchange.Data.ExchangeObjectVersion ExchangeVersion {get;}
ExternalDirectoryObjectId Property System.String ExternalDirectoryObjectId {get;}
Flags Property Microsoft.Exchange.Data.Directory.Recipient.RequestFlags Flags {get;}
Guid Property System.Guid Guid {get;}
Identity Property Microsoft.Exchange.Data.ObjectId Identity {get;}
IsOffline Property System.Boolean IsOffline {get;}
IsValid Property System.Boolean IsValid {get;}
LastExchangeChangedTime Property System.Nullable`1[[System.DateTime, mscorlib, Version=2.0.0.0, Culture=neutr...
Name Property System.String Name {get;set;}
OrganizationId Property Microsoft.Exchange.Data.Directory.OrganizationId OrganizationId {get;}
OriginatingServer Property System.String OriginatingServer {get;}
Protect Property System.Boolean Protect {get;}
RecipientType Property Microsoft.Exchange.Data.Directory.Recipient.RecipientType RecipientType {get;}
RecipientTypeDetails Property Microsoft.Exchange.Data.Directory.Recipient.RecipientTypeDetails RecipientTy...
RemoteHostName Property System.String RemoteHostName {get;}
RequestStyle Property Microsoft.Exchange.MailboxReplicationService.RequestStyle RequestStyle {get;}
SourceArchiveDatabase Property Microsoft.Exchange.Data.Directory.ADObjectId SourceArchiveDatabase {get;}
SourceDatabase Property Microsoft.Exchange.Data.Directory.ADObjectId SourceDatabase {get;}
Status Property Microsoft.Exchange.Data.Directory.Recipient.RequestStatus Status {get;}
Suspend Property System.Boolean Suspend {get;}
SuspendWhenReadyToComplete Property System.Boolean SuspendWhenReadyToComplete {get;}
TargetArchiveDatabase Property Microsoft.Exchange.Data.Directory.ADObjectId TargetArchiveDatabase {get;}
TargetDatabase Property Microsoft.Exchange.Data.Directory.ADObjectId TargetDatabase {get;}
Here are the members of the target
TypeName: Microsoft.Exchange.Data.Mapi.MailboxStatistics
Name MemberType Definition
---- ---------- ----------
Clone Method System.Object Clone()
Dispose Method System.Void Dispose()
Equals Method bool Equals(System.Object obj)
GetDisposeTracker Method Microsoft.Exchange.Diagnostics.DisposeTracker GetDisposeTracker()
GetHashCode Method int GetHashCode()
GetProperties Method System.Object[] GetProperties(System.Collections.Generic.ICollection[Microsoft....
GetType Method type GetType()
SuppressDisposeTracker Method System.Void SuppressDisposeTracker()
ToString Method string ToString()
Validate Method Microsoft.Exchange.Data.ValidationError[] Validate()
PSComputerName NoteProperty System.String PSComputerName=nycexhc01.nfp.com
RunspaceId NoteProperty System.Guid RunspaceId=dc444c7e-bcac-4c1c-8fdf-847875456c03
AssociatedItemCount Property System.Nullable`1[[System.UInt32, mscorlib, Version=2.0.0.0, Culture=neutral, P...
Database Property Microsoft.Exchange.Data.ObjectId Database {get;}
DatabaseName Property System.String DatabaseName {get;}
DeletedItemCount Property System.Nullable`1[[System.UInt32, mscorlib, Version=2.0.0.0, Culture=neutral, P...
DisconnectDate Property System.Nullable`1[[System.DateTime, mscorlib, Version=2.0.0.0, Culture=neutral,...
DisconnectReason Property System.Nullable`1[[Microsoft.Exchange.Data.Mapi.MailboxState, Microsoft.Exchang...
DisplayName Property System.String DisplayName {get;}
Identity Property Microsoft.Exchange.Data.Mapi.MailboxId Identity {get;}
IsArchiveMailbox Property System.Nullable`1[[System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, ...
IsQuarantined Property System.Boolean IsQuarantined {get;}
IsValid Property System.Boolean IsValid {get;}
ItemCount Property System.Nullable`1[[System.UInt32, mscorlib, Version=2.0.0.0, Culture=neutral, P...
LastLoggedOnUserAccount Property System.String LastLoggedOnUserAccount {get;}
LastLogoffTime Property System.Nullable`1[[System.DateTime, mscorlib, Version=2.0.0.0, Culture=neutral,...
LastLogonTime Property System.Nullable`1[[System.DateTime, mscorlib, Version=2.0.0.0, Culture=neutral,...
LegacyDN Property System.String LegacyDN {get;}
MailboxGuid Property System.Guid MailboxGuid {get;}
MailboxTableIdentifier Property System.String MailboxTableIdentifier {get;}
MapiIdentity Property Microsoft.Exchange.Data.Mapi.MapiObjectId MapiIdentity {get;}
MoveHistory Property System.Object MoveHistory {get;}
ObjectClass Property Microsoft.Exchange.Data.Mapi.ObjectClass ObjectClass {get;}
OriginatingServer Property Microsoft.Exchange.Data.Fqdn OriginatingServer {get;}
ServerName Property System.String ServerName {get;}
StorageLimitStatus Property System.Nullable`1[[Microsoft.Exchange.Data.Mapi.StorageLimitStatus, Microsoft.E...
TotalDeletedItemSize Property Microsoft.Exchange.Data.Unlimited`1[[Microsoft.Exchange.Data.ByteQuantifiedSize...
TotalItemSize Property Microsoft.Exchange.Data.Unlimited`1[[Microsoft.Exchange.Data.ByteQuantifiedSize...
The documentation is not clear on what Get-MoveRequest returns, but something like below is what you can try:
Get-MoveRequest ... | select -expand Name | Get-MBStats