Active IQ Unified Manager Discussions

How to load a new Module in WFA

narendrathawani
5,623 Views

Has anyone added a PowerShell Module in WFA ?

I tried following steps to add 2.1 NTFSSecurity Module. I have all the Modules in C:\Program Files\netapp\WFA\PoSH\Modules      directory.

PS C:\Program Files\netapp\wfa\PoSH> type profile.ps1
$ModulesDir = split-path $MyInvocation.MyCommand.Path

Import-Module $ModulesDir\Modules\WFA
Import-Module $ModulesDir\Modules\WFAWrapper
Import-Module $ModulesDir\Modules\DataONTAP
Import-Module $ModulesDir\Modules\NTFSSecurity

PS C:\Program Files\netapp\wfa\PoSH> dir

    Directory: C:\Program Files\netapp\wfa\PoSH

Mode    Inherits             LastWriteTime    Size(M) Name
----    --------             -------------    ------- ----
d----       True       4/24/2013   5:20 PM            Modules
-a---       True       4/24/2013   3:12 PM          0 profile.ps1

PS C:\Program Files\netapp\wfa\PoSH> cd modules
PS C:\Program Files\netapp\wfa\PoSH\modules> dir

    Directory: C:\Program Files\netapp\wfa\PoSH\modules

Mode    Inherits             LastWriteTime    Size(M) Name
----    --------             -------------    ------- ----
d----       True        4/3/2013   7:47 AM            DataONTAP
d----       True       4/24/2013   5:20 PM            NTFSSecurity
d----       True        4/3/2013   7:47 AM            WFA
d----       True        4/3/2013   7:47 AM            WFAWrapper

PS C:\Program Files\netapp\wfa\PoSH\modules>

After restarting of WFA services and Reboot of WFA server, I still see same message in WFA logs that The term 'Add-Ace' is not recognized as the name of a cmdlet

Any help would be much appreciated.

8 REPLIES 8

kandati
5,624 Views

Hi,

Can you please try to list the modules imported by running following command-let,

#Get-Module

and see whether your NTFSSecurity module is loaded or not..!!


I have just downloaded NTFSSecutiry module from internet and imported it successfully,

PS C:\Users\kandati\Downloads\NTFSSecurity 2.1 Binaries> Get-Module

_______________________________________________________________________________________________________________________________________________________________________________________________________________________________

PS C:\Users\kandati\Downloads\NTFSSecurity 2.1 Binaries> Import-Module .\NTFSSecurity

Types added

NTFSSecurity Module loaded

_______________________________________________________________________________________________________________________________________________________________________________________________________________________________

PS C:\Users\kandati\Downloads\NTFSSecurity 2.1 Binaries> Get-Module

ModuleType Name                      ExportedCommands                                                          

---------- ----                      ----------------                                                          

Binary     NTFSSecurity              {Show-SimpleEffectiveAccess, Get-Inheritance, Set-Owner, Get-SimpleEffec...

_______________________________________________________________________________________________________________________________________________________________________________________________________________________________

PS C:\Users\kandati\Downloads\NTFSSecurity 2.1 Binaries> add-ace -?

NAME

    Add-Access

   

SYNTAX

    Add-Access [-Path] <String[]> [-Account] <IdentityReference2> [-AccessRights] <FileSystemRights2> [-AccessType <AccessControlType>] [-InheritanceFlags <InheritanceFlags>] [-PropagationFlags <PropagationFlags>] [-PassThru]

    [-Verbose] [-Debug] [-ErrorAction <ActionPreference>] [-WarningAction <ActionPreference>] [-ErrorVariable <String>] [-WarningVariable <String>] [-OutVariable <String>] [-OutBuffer <Int32>]

    Add-Access [-Path] <String[]> [-Account] <IdentityReference2> [-AccessRights] <FileSystemRights2> [-AccessType <AccessControlType>] [-AppliesTo <ApplyTo>] [-PassThru] [-Verbose] [-Debug] [-ErrorAction <ActionPreference>] [

    -WarningAction <ActionPreference>] [-ErrorVariable <String>] [-WarningVariable <String>] [-OutVariable <String>] [-OutBuffer <Int32>]

   

_______________________________________________________________________________________________________________________________________________________________________________________________________________________________

It asked few security checks while importing it. But I haven't tried this adding it to profile.ps1

I can get back to you on doing your way..!!

Warm Regards

Sivaprasad K

narendrathawani
5,624 Views

Yes, It works fine from command line. It doesn't work from WFA when I add "Import-Module $ModulesDir\Modules\NTFSSecurity" in "profile.ps1"

Thanks for looking into it.

goodrum
5,624 Views

The approach that you are trying works but there is one difference between how it is imported via the command line and when the profile.ps1 is read.  I have tested this in my lab and found that in the latter, there is no Alias created.  Get-Ace is actually an alias for Get-Access.  I noticed this in the PS1 file that is included in the package.  (New-Alias -Name Get-Ace -Value Get-Access).  It turns out that the module will import with no issues (as long as the path and ALL of the included files are there.  Don't leave any of them out).  After running the WFA profile.ps1 from the CLI.  I got the same exact error as you.  This is when I decided to try the real cmdlet name and it worked.  I tried to manually add the New-Alias command to the profile.ps1 and that didn't work. 

It looks like there are only a couple of aliases that would be created so it might not be that big of an issue.  I can't figure out why it is not setting up the Aliases.  What I found odd was when I manually added the below lines to the profile.ps1, I received an error that the Alias already exists but Get-Alias doesn't show those. 

New-Alias -Name Get-Ace -Value Get-Access

New-Alias -Name Add-Ace -Value Add-Access

New-Alias -Name Remove-Ace -Value Remove-Access

New-Alias -Name Get-OrphanedAce -Value Get-OrphanedAccess

Anyway, I can confirm that things worked.  I added the Import-Module to the WFA profile.ps1 and then restarted the service.  I created a new test Command with a very simple script:

--------------------------------------------

$security = Get-Access -Path "C:\wfa"

Get-WFALogger -message ("Here is the information")

Get-WFALogger -message ($security[0].Account.AccountName)

--------------------------------------------

I clicked the TEST button and no issues:

--------------------------------------------

10:39:46.029 INFO  [Get File Permissions] ### Command 'Get File Permissions' ###

10:39:47.201 INFO  [Get File Permissions] Executing command: ./Get_File_Permissions836740177284623151.ps1

10:39:47.232 DEBUG  [Get File Permissions] Here is the information

10:39:47.248 DEBUG  [Get File Permissions] NT AUTHORITY\SYSTEM

10:39:47.295 INFO  [Get File Permissions] Command completed, took 1250 milliseconds

Jeremy Goodrum, NetApp

The Pirate

Twitter: @virtpirate

Blog: www.virtpirate.com

kandati
5,624 Views

Hi,

I was playing with this module to make aliases to be working and finally found a solution..!!

The issue is that they are not exporting the aliases created by this module.

To make them exported, I have slightly tweaked the module as below,

1) Created a new file called, NTFSSecurity.Alias.psm1 under NTFSSecurity directory with aliases exported as below,

Set-Alias -Name Get-Ace -Value Get-Access

Set-Alias -Name Add-Ace -Value Add-Access

Set-Alias -Name Remove-Ace -Value Remove-Access

Set-Alias -Name Get-OrphanedAce -Value Get-OrphanedAccess

Export-ModuleMember -Alias Get-Ace

Export-ModuleMember -Alias Add-Ace

Export-ModuleMember -Alias Remove-Ace

Export-ModuleMember -Alias Get-OrphanedAce

2) Modify the file NTFSSecurity.psd1 as, search for "NestedModules" then assign the above file to it like below,

NestedModules = @('NTFSSecurity.Alias.psm1')

3) Now run profile.ps1 and that's it,  then you would be able to see the aliases

Hope this helps..!!

PS: Took the reference of DataONTAP module. Not sure, how safe to play like this 🙂

Warm Regards

Sivaprasad K

kandati
5,624 Views

Hi,

Were you able to proceed with NTFSSecurity module..!!

-Siva

narendrathawani
5,624 Views

Jeremy and Siva,

Thanks! Looks like using full command (Add-Access) works.

But I get following error

Get-Item \\toaster1\c$\vol\vol_non_prod_3\Naren_Test|Add-Access -Account MS\group1 -AccessRights FullControl

10:09:39.053 ERROR  [Set File Permissions] Failed executing command. Exception: Cannot find path '\\toaster1\c$\vol\vol_non_prod_3\Naren_Test' because it does not exist.

I must be using wrong syntax. Any suggestion on how to specify the path of the file / folder that requires ACL changes.

Thanks!

kandati
5,624 Views

Hi,

I'm not sure, I think you are using some network path.

Can you try mapping it to some local drive like, Z:, and use that drive in the script..!!

-Siva

narendrathawani
5,624 Views

From WFA

Connect-WFAController -Array $Array

mount-nacontroller

Get-Item taoster1:\vol\vol_non_prod_3\Naren_Test                     (works)
Get-Item toaster1:\vol\vol_non_prod_3\Naren_Test | Get-Access      (Fails with error "Failed executing command. Exception: Unable to find the specified file."

Does that means Get-Access can't work with mounted drives ?

On Command line :
PS C:\Users\user1> Get-Item \\toaster1\c$\vol\vol_non_prod_3\Naren_Test|Get-Ace       (Works)
but fails from WFA with following error
Get-Item \\toaster1\c$\vol\vol_non_prod_3\Naren_Test
10:09:39.053 ERROR  [Set File Permissions] Failed executing command. Exception: Cannot find path '\\toaster1\c$\vol\vol_non_prod_3\Naren_Test' because it does not exist.

Does that means from WFA, we can't define share path ?

Public