0

Windows Server 2012 R2 のファイル サーバー リソース マネージャーの分類ルール内で Active Directory PowerShell モジュールを使用しようとしています。

ただ実行しようとすると:

Import-Module ActiveDirectory

それはクラッシュし(私は推測します)、分類プロパティを更新しなくなります。

スクリプト パラメータ -ExecutionPolicy Unrestricted を設定しようとしましたが、役に立ちませんでした。

誰でもそれを機能させる方法を知っていますか?

前もって感謝します、

エリック

追加された非動作コードを更新します。

# Global variables available:
# $ModuleDefinition  (IFsrmPipelineModuleDefinition)
# $Rule  (IFsrmClassificationRule)
# $PropertyDefinition  (IFsrmPropertyDefinition)
#
# And (optionally) any parameters you provide in the Script parameters box below,
# i.e. "$a = 1; $b = 2" . The string you enter is treated as a script and executed so the
# variables you define become globally available

# optional function to specify when the behavior of this script was last modified
# if it consumes additional files. emit one value of type DateTime
#
# function LastModified
# {
# }

# required function that outputs a value to be assigned to the specified property for each file classified
# emitting no value is allowed, which causes no value to be assigned for the property
# emitting more than one value will result in errors during classification
# begin and end are optional; process is required
#
function GetPropertyValueToApply
{
    # this parameter is of type IFsrmPropertyBag
    # it also has an additional method, GetStream, which returns a IO.Stream object to use for
    # reading the contents of the file. Make sure to close the stream after you are done reading
    # from the file
    param
    (
        [Parameter(Position = 0)] $PropertyBag
    )

    process
    {
        Import-Module activedirectory   
        $users = Get-ADUser -filter * -Properties SID,Department
        return "dummy result";
    }
}

注: これは、powershell コンソールでは問題なく動作しますが、それは問題ではありません。ファイル サーバー リソース マネージャーの分類子としてコードを実行しています。

Get-ADUser の結果を使用して CSV ファイルを作成し、それをスクリプト内にロードするだけで、これを回避することができました (したがって、非標準モジュールは必要ありません)。しかし、外部タスクに依存せずにこれを実行する方が良いでしょう:-)

4

1 に答える 1

0

解決済み (少しばかげているように感じます :-()、誰かが同じ問題を抱えている場合の参考のために。

分類スクリプトは、システム アカウントで実行されているファイル サーバー リソース マネージャー サービスから (見ている UI からではなく) 実行されます。

そのため、サービスが実行されているアカウントを変更するか、アクセスする必要のあるオブジェクトにアクセスする権限をアカウントに付与する必要があります。私の場合、Active Directory.

于 2015-04-30T08:02:28.123 に答える