Skip to content

Commit

Permalink
Improve translation
Browse files Browse the repository at this point in the history
  • Loading branch information
PrzemyslawKlys committed Mar 8, 2023
1 parent d2f8931 commit b038aaa
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 21 deletions.
87 changes: 72 additions & 15 deletions Public/Computers/Get-ComputerSMBShare.ps1
Original file line number Diff line number Diff line change
@@ -1,25 +1,82 @@
function Get-ComputerSMBShare {
[CmdletBinding()]
param(
[string[]] $ComputerName
[string[]] $ComputerName,
[switch] $Translated
)
[Array] $CollectionComputers = Get-ComputerSplit -ComputerName $ComputerName
$SMB = @(
if ($CollectionComputers[0].Count -gt 0) {
$Output = Get-SmbShare
foreach ($_ in $Output) {

if ($CollectionComputers[0].Count -gt 0) {
$Output = Get-SmbShare
foreach ($O in $Output) {
if (-not $Translated) {
Add-Member -InputObject $_ -Name 'PSComputerName' -Value $Env:COMPUTERNAME -MemberType NoteProperty -Force
$_
$O
} else {
[PSCustomObject] @{
Name = $O.Name #: ADMIN$
ScopeName = $O.ScopeName #: *
Path = $O.Path #: C:\Windows
Description = $O.Description #: Remote Admin
ComputerName = $O.PSComputerName #: AD1
PresetPathAcl = $O.PresetPathAcl #:
ShareState = $O.ShareState.ToString() #: Online
AvailabilityType = $O.AvailabilityType.ToString() #: NonClustered
ShareType = $O.ShareType.ToString() #: FileSystemDirectory
FolderEnumerationMode = $O.FolderEnumerationMode.ToString() #: Unrestricted
CachingMode = $O.CachingMode.ToString() #: Manual
LeasingMode = $O.LeasingMode.ToString() #:
QoSFlowScope = $O.QoSFlowScope #:
SmbInstance = $O.SmbInstance.ToString() #: Default
CATimeout = $O.CATimeout #: 0
ConcurrentUserLimit = $O.ConcurrentUserLimit #: 0
ContinuouslyAvailable = $O.ContinuouslyAvailable #: False
CurrentUsers = $O.CurrentUsers #: 0
EncryptData = $O.EncryptData #: False
Scoped = $O.Scoped #: False
SecurityDescriptor = $O.SecurityDescriptor #: O:SYG:SYD:(A;;GA;;;BA)(A;;GA;;;BO)(A;;GA;;;IU)
ShadowCopy = $O.ShadowCopy #: False
Special = $O.Special #: True
Temporary = $O.Temporary #: False
Volume = $O.Volume #: \\?\Volume{2014dd39-5b27-44a6-be88-1d650346016d}\
}
}
}
if ($CollectionComputers[1].Count -gt 0) {
$Output = Get-SmbShare -CimSession $CollectionComputers[1]
foreach ($_ in $Output) {
$_
}
if ($CollectionComputers[1].Count -gt 0) {
$Output = Get-SmbShare -CimSession $CollectionComputers[1]
foreach ($O in $Output) {
if (-not $Translated) {
$O
} else {
[PSCustomObject] @{
Name = $O.Name #: ADMIN$
ScopeName = $O.ScopeName #: *
Path = $O.Path #: C:\Windows
Description = $O.Description #: Remote Admin
ComputerName = $O.PSComputerName #: AD1
PresetPathAcl = $O.PresetPathAcl #:
ShareState = $O.ShareState.ToString() #: Online
AvailabilityType = $O.AvailabilityType.ToString() #: NonClustered
ShareType = $O.ShareType.ToString() #: FileSystemDirectory
FolderEnumerationMode = $O.FolderEnumerationMode.ToString() #: Unrestricted
CachingMode = $O.CachingMode.ToString() #: Manual
LeasingMode = $O.LeasingMode #.ToString() #:
QoSFlowScope = $O.QoSFlowScope #:
SmbInstance = $O.SmbInstance.ToString() #: Default
CATimeout = $O.CATimeout #: 0
ConcurrentUserLimit = $O.ConcurrentUserLimit #: 0
ContinuouslyAvailable = $O.ContinuouslyAvailable #: False
CurrentUsers = $O.CurrentUsers #: 0
EncryptData = $O.EncryptData #: False
Scoped = $O.Scoped #: False
SecurityDescriptor = $O.SecurityDescriptor #: O:SYG:SYD:(A;;GA;;;BA)(A;;GA;;;BO)(A;;GA;;;IU)
ShadowCopy = $O.ShadowCopy #: False
Special = $O.Special #: True
Temporary = $O.Temporary #: False
Volume = $O.Volume #: \\?\Volume{2014dd39-5b27-44a6-be88-1d650346016d}\
}
}
}
)
$SMB
}

#Get-ComputerSMBShare -ComputerName AD1, EVOWIN | ft -AutoSize Name, PSComputerName
}
}
35 changes: 29 additions & 6 deletions Public/Computers/Get-ComputerSMBSharePermissions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
[CmdletBinding()]
param(
[string[]] $ComputerName,
[Parameter(Mandatory = $true)][alias('Name')][string[]] $ShareName
[Parameter(Mandatory = $true)][alias('Name')][string[]] $ShareName,
[switch] $Translated
)
[Array] $Computers = Get-ComputerSplit -ComputerName $ComputerName
if ($Computers[0].Count -gt 0) {
Expand All @@ -13,9 +14,20 @@
$ErrorMessage = $_.Exception.Message
Write-Warning -Message "Get-ComputerSMBSharePermissions - Computer $Env:COMPUTERNAME, Share $Share, Error: $ErrorMessage"
}
foreach ($_ in $Output) {
Add-Member -InputObject $_ -Name 'PSComputerName' -Value $Env:COMPUTERNAME -MemberType NoteProperty -Force
$_
foreach ($O in $Output) {
if (-not $Translated) {
$O | Add-Member -Name 'PSComputerName' -Value $Env:COMPUTERNAME -MemberType NoteProperty -Force
$O
} else {
[PSCustomObject] @{
Name = $O.Name #: NETLOGON
ScopeName = $O.ScopeName #: *
AccountName = $O.AccountName.ToString() #: Everyone
AccessControlType = $O.AccessControlType.ToString() #: Allow
AccessRight = $O.AccessRight.ToString() #: Read
ComputerName = $Env:COMPUTERNAME #: AD2.AD.EVOTEC.XYZ
}
}
}
}
}
Expand All @@ -27,8 +39,19 @@
$ErrorMessage = $_.Exception.Message
Write-Warning -Message "Get-ComputerSMBSharePermissions - Computer $($Computers[1]), Share $Share, Error: $ErrorMessage"
}
foreach ($_ in $Output) {
$_
foreach ($O in $Output) {
if (-not $Translated) {
$O
} else {
[PSCustomObject] @{
Name = $O.Name #: NETLOGON
ScopeName = $O.ScopeName #: *
AccountName = $O.AccountName.ToString() #: Everyone
AccessControlType = $O.AccessControlType.ToString() #: Allow
AccessRight = $O.AccessRight.ToString() #: Read
ComputerName = $O.PSComputerName #: AD2.AD.EVOTEC.XYZ
}
}
}
}
}
Expand Down

0 comments on commit b038aaa

Please sign in to comment.