Skip to content

Instantly share code, notes, and snippets.

@pldmgg
Created October 25, 2018 23:46
Show Gist options
  • Select an option

  • Save pldmgg/ebe9eb223b4a816607ad8942f395e081 to your computer and use it in GitHub Desktop.

Select an option

Save pldmgg/ebe9eb223b4a816607ad8942f395e081 to your computer and use it in GitHub Desktop.
foreach ($ModuleItem in $ModulesToInstallAndImport) {
if ($PSVersionTable.Platform -eq "Unix" -or $PSVersionTable.OS -match "Darwin") {
# Make sure the Module Manifest file name and the Module Folder name are exactly the same case
$env:PSModulePath -split ':' | foreach {
Get-ChildItem -Path $_ -Directory | Where-Object {$_ -match $ModuleItem.Name}
} | foreach {
$ManifestFileName = $(Get-ChildItem -Path $_ -Recurse -File | Where-Object {$_.Name -match "$($ModuleItem.Name)\.psd1"}).BaseName
$ModuleFileName = $(Get-ChildItem -Path $_ -Recurse -File | Where-Object {$_.Name -match "$($ModuleItem.Name)\.psm1"}).BaseName
if (![bool]$($_.Name -cmatch $ManifestFileName)) {
Rename-Item $_ $ManifestFileName
}
if (![bool]$($_.Name -cmatch $ModuleFileName)) {
Rename-Item $_ $ModuleFileName
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment