小编Ric*_*ard的帖子

从网络共享复制 PowerShell DSC

我正在尝试使用 PowerShell DSC 从网络共享复制文件夹内容。这是代码:

Configuration TestSetup {
    Node localhost {
        File Test {
            SourcePath = "\\Server\SomeShare\SomeFolder"
            DestinationPath = "E:\test"
            Recurse = $true
            Type = "Directory"
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

但是,这不起作用 - 当我运行它时,我收到以下错误消息:

The related file/directory is: \\Server\SomeShare\SomeFolder.
The path cannot point to the root directory or to the root of a net share.
SourcePath must be specified if you want to configure the destination directory recursively. Make sure that SourcePath is a directory and that it is accessible.
    + CategoryInfo          : …
Run Code Online (Sandbox Code Playgroud)

windows powershell network-share dsc

17
推荐指数
2
解决办法
2万
查看次数

如何让 Nginx 将对不存在的文件的所有请求重定向到单个 php 文件?

我有以下 nginx vhost 配置:

server {
    listen 80 default_server;

    access_log /path/to/site/dir/logs/access.log;
    error_log /path/to/site/dir/logs/error.log;

    root /path/to/site/dir/webroot;
    index index.php index.html;

    try_files $uri /index.php;

    location ~ \.php$ {
            if (!-f $request_filename) {
                    return 404;
            }

            fastcgi_pass localhost:9000;
            fastcgi_param SCRIPT_FILENAME /path/to/site/dir/webroot$fastcgi_script_name;
            include /path/to/nginx/conf/fastcgi_params;
    }
}
Run Code Online (Sandbox Code Playgroud)

我想重定向所有与 index.php 存在的文件不匹配的请求。这适用于目前大多数 URI,例如:

example.com/asd
example.com/asd/123/1.txt
Run Code Online (Sandbox Code Playgroud)

无论是中asdasd/123/1.txt存在,所以他们重定向到的index.php和工作正常。但是,如果我输入 url example.com/asd.php,它会尝试查找asd.php,当找不到时,它会返回 404 而不是将请求发送到index.php

有没有得到一个方式asd.php进行也发送到index.php如果asd.php不存在?

php nginx redirect php-fpm

8
推荐指数
2
解决办法
6万
查看次数

PowerShell DSC 组资源 - “找不到具有提供名称的主体”

我正在尝试使用 PowerShell DSC 将域组添加到本地管理员组。这是代码:

Configuration TestSetup {
    Node localhost {
        Group Administrators {
            GroupName = "Administrators"
            MembersToInclude = "MYDOMAIN\TheAdministratorsGroup"
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

当我运行它时,这会导致以下错误:

PowerShell provider MSFT_GroupResource  failed to execute Test-TargetResource functionality with error message: Could not find a principal with the provided name [mydomain\theadministratorsgroup]
    + CategoryInfo          : InvalidOperation: (:) [], CimException
    + FullyQualifiedErrorId : ProviderOperationExecutionFailure
    + PSComputerName        : localhost
Run Code Online (Sandbox Code Playgroud)

主体确实存在,我可以通过 GUI 手动添加它并使用net localgroup.

我知道 DSC 配置是在该SYSTEM帐户下执行的,所以我认为这可能是SYSTEM想要查询 Active Directory的帐户的权限问题。但是,我已经SYSTEM使用 PsExec将 cmd 作为帐户运行,并且能够毫无问题地将域组添加到本地管理员组。

windows powershell active-directory groups dsc

8
推荐指数
1
解决办法
3197
查看次数

嵌套来自不同文件的 PowerShell DSC 配置

如果我将 DSC 配置嵌套在这样的单个文件中,它可以正常工作:

Configuration Secondary {
    Param ($SomeParameter)

    Environment Test {
        Name = $SomeParameter
        Value = "12345"
    }
}

Configuration MyConfiguration {
    Node localhost {
        Secondary TheSecondary {
            SomeParameter = "TestEnvVar"
        }
    }
}

MyConfiguration

Start-DscConfiguration .\MyConfiguration -Wait -Verbose
Run Code Online (Sandbox Code Playgroud)

我想将我的配置分成两个单独的文件。一个将点源另一个以包含配置。

次要.ps1:

Configuration Secondary {
    Param ($SomeParameter)

    Environment Test {
        Name = $SomeParameter
        Value = "12345"
    }
}
Run Code Online (Sandbox Code Playgroud)

主要.ps1:

. .\Secondary.ps1

Configuration MyConfiguration {
    Node localhost {
        Secondary TheSecondary {
            SomeParameter = "TestEnvVar"
        }
    }
}

MyConfiguration

Start-DscConfiguration .\MyConfiguration -Wait -Verbose …
Run Code Online (Sandbox Code Playgroud)

powershell dsc

7
推荐指数
1
解决办法
5987
查看次数