小编Jas*_*son的帖子

PowerShell和表达式中的空间

我有一个名为CSV的字段.但是,我想将其重命名为Name.

我在下面有以下代码.但是,我不知道如何处理t和之间的空间N.

我尝试过使用引号和其他一些技巧,但到目前为止还没有用过.我需要做些什么才能获得价值?

Import-Csv .\Downloads\addata.csv | Select @{n="Name";e={$_.First Name}}
Run Code Online (Sandbox Code Playgroud)

powershell select import-csv

3
推荐指数
1
解决办法
420
查看次数

使 Bash 模块化

我有一堆 Bash 脚本,它们每个都使用以下内容:

BIN_CHATTR="/usr/bin/chattr"
BIN_CHKCONFIG="/sbin/chkconfig";
BIN_WGET="/usr/bin/wget";
BIN_TOUCH="/bin/touch";
BIN_TAR="/bin/tar";
BIN_CHMOD="/bin/chmod";
BIN_CHOWN="/bin/chown";
BIN_ECHO="/bin/echo";
BIN_GUNZIP="/usr/bin/gunzip";
BIN_PATCH="/usr/bin/patch";
BIN_FIND="/usr/bin/find";
BIN_RM="/bin/rm";
BIN_USERDEL="/usr/sbin/userdel";
BIN_GROUPDEL="/usr/sbin/groupdel";
BIN_MOUNT="/bin/mount";
Run Code Online (Sandbox Code Playgroud)

有没有一种方法可以让我得到一个具有全局设置的 Bash 脚本,然后将它们包含在我想要运行的脚本中?

linux bash shell

2
推荐指数
1
解决办法
1965
查看次数

授予访问权限以读取Amazon S3存储桶中的子目录

我之前从未使用过AWS S3.我们使用它来自动备份客户的通话录音.我们的一个用于审计目的的客户需要访问他们的录音.

我使用客户端Cyber​​Duck作为访问文件的方式.

我想让他们只访问他们的文件.

我们的文件结构如下:

recordings/12345/COMPANYNAMEHERE/
Run Code Online (Sandbox Code Playgroud)

我刚学会根据脚本和策略构建和执行操作.所以我做了一些研究,并尝试建立一个,但我在上市时获得拒绝访问权限.

只是好奇我是否正确地解决了这个问题.

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": "s3:ListAllMyBuckets",
            "Resource": "arn:aws:s3:::*"
        },
        {
            "Effect": "Allow",
            "Action": "s3:*",
            "Resource": [
                "arn:aws:s3:::recordings/12345/COMPANYNAMEHERE",
                "arn:aws:s3:::recordings/12345/COMPANYNAMEHERE/*"
            ]
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

acl amazon-s3 amazon-web-services

2
推荐指数
1
解决办法
1229
查看次数

有没有办法与任何用户一起使用ConvertFrom-SecureString和ConvertTo-SecureString?

我正在使用以下内容来创建密码文件:

$path = "C:\Users\USER\Desktop"
$passwd = Read-Host "enter desired password" -AsSecureString
$encpwd = ConvertFrom-SecureString $passwd
$encpwd > $path\filename.bin
Run Code Online (Sandbox Code Playgroud)

然后使用以下命令调用文件:

# define path to store password and input password 
$path = "C:\Users\USER\Desktop"
# get the encrypted password from the path
$encpwd = Get-Content $path\filename.bin
# convert file to secure string 
$passwd = ConvertTo-SecureString $encpwd
# define needed credential 
$cred = new-object System.Management.Automation.PSCredential 'WIN-SERVER\AdminForQB',$passwd
# go to DVD drive launch setup.exe as user with privileges to launch the program with no user …
Run Code Online (Sandbox Code Playgroud)

powershell windows-10

2
推荐指数
1
解决办法
5480
查看次数

Powershell get-service管道停止流程

Get-Service | Stop-Process -Name WSearch -WhatIf
Run Code Online (Sandbox Code Playgroud)

Stop-Process:输入对象不能绑定到命令的任何参数,因为该命令不接受管道输入或输入及其属性与接受管道输入的任何参数都不匹配.在线:1字符:15 + Get-Service | Stop-Process -Name WSearch -WhatIf + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo:InvalidArgument:(fdPHost :PSObject)[Stop-Process],ParameterBindingException + FullyQualifiedErrorId:InputObjectNotBound,Microsoft.PowerShell.Commands.StopProcessCommand

现在从我的理解,他们都共享相同的属性名称"名称",所以我应该能够通过-Name管道,对吧?

PS C:\> Get-Service | gm
   TypeName: System.ServiceProcess.ServiceController
Name                      MemberType    Definition
----                      ----------    ----------
Name                      AliasProperty Name = ServiceName

get-help stop-process

    -Name <String[]>
        Specifies the process names of the processes to be stopped. You can type multiple process names (separated by commas) or use wildcard characters.

        Required?                    true
        Position?                    named
        Default value                
        Accept pipeline input?       true (ByPropertyName)
        Accept wildcard …
Run Code Online (Sandbox Code Playgroud)

windows powershell

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

使用Powershell安装多个应用程序

Get-Url http://dl.google.com/chrome/install/375.126/chrome_installer.exe c:\temp\chrome_installer.exe;
c:\temp\chrome_installer.exe /silent /install;
Run Code Online (Sandbox Code Playgroud)

我有以下几点。但是我也喜欢在chrome之后安装其他应用程序。这是正确的方法还是我会遇到问题,因为Powershell不知道何时完成安装以及何时启动另一安装?

我应该改走MSI路线吗?

powershell

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

从具有相同列名的mysql数组中获取值

SELECT * 
    FROM companies 
    LEFT JOIN (ownership_reseller_to_company, users) 
    ON (users.ID=ownership_reseller_to_company.RESELLER_ID AND ownership_reseller_to_company.COMPANY_ID=companies.ID) 
    WHERE companies.NAME LIKE '%".$search_parm."%' AND users.ID='".$_USERID."'
Run Code Online (Sandbox Code Playgroud)

我的问题是我有NAME companies和NAME,users但是当我使用时,$row['NAME'];我得到了NAME users.有没有办法让一个人companies?我试过$ row ['companies.NAME'],但没有成功.

php mysql

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