GVKun编程网logo

PowerShell 2.0 sudo的限制(powershell最高权限)

17

想了解PowerShell2.0sudo的限制的新动态吗?本文将为您提供详细的信息,我们还将为您解答关于powershell最高权限的相关问题,此外,我们还将为您介绍关于Kubernetespower

想了解PowerShell 2.0 sudo的限制的新动态吗?本文将为您提供详细的信息,我们还将为您解答关于powershell最高权限的相关问题,此外,我们还将为您介绍关于Kubernetes powershell 模块的 Powershell cmdlet 参考、Microsoft.SharePoint.PowerShellpipe理单元:不正确的Windows PowerShell版本3.0 当前控制台支持Window PowerShell 2.0版、MSSQL/WMI/PowerShell结合篇(四)PowerShell发送微信信息、Powershell – 使用Powershell对Azure AD应用程序执行“授予权限”操作的新知识。

本文目录一览:

PowerShell 2.0 sudo的限制(powershell最高权限)

PowerShell 2.0 sudo的限制(powershell最高权限)

很长时间的读者,但新的海报。 我一直在为这个问题摔跤了一整天,这让我疯狂。 淘了这个网站和谷歌后,我仍然卡住了。 基本上,我无法弄清楚如何在PowerShell中使用copy-Item CmdLet来实现“sudo”。 这是我的代码:

PROFILE.PS1:

# Trigger UAC to elevate the supplied command function Elevate-Process() { if($args.Length -eq 0) { error ('USAGE: ' + $MyInvocation.InvocationName + ' <executable> [arg1 arg2 arg3 ...]'); } else { try { if($args.Length -eq 1) { start-process $args[0] -Verb RunAs; } else { start-process $args[0] -ArgumentList $args[1..$args.Length] -Verb RunAs; } } catch { error $_.Exception.Message; } } } # display pretty-formatted error messages function error() { # Validate function parameters Param( [Parameter(Mandatory=$true)] [ValidateScript({$_.GetType().Name -eq 'String'})] $sMessage ); Write-Host $sMessage -BackgroundColor Yellow -ForegroundColor Red; } # Set aliases set-alias sudo Elevate-Process;

应用 – INI.PS1:

sudo copy-Item '.standard_menu.ini' 'C:Program Files (x86)Operaui'; #sudo [System.IO.File]::copy '.webmailproviders.ini' 'C:Program Files (x86)Operadefaultswebmailproviders.ini' $true; Write-Host 'Press any key to exit...'; $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") | Out-Null;

当我执行powershell.exe。 apply-ini.ps1时 ,出现以下错误:

由于错误,此命令无法执行:系统找不到指定的文件。

我已经尝试了所有我可能find没有任何运气。 希望有人能指出我正确的方向。

.NET:如何创build文件图标叠加

如何在SaveFileDialog的默认FileName中设置长string(> 260)?

找出当前用户的用户名 – 当多个用户login时

将函数包装到Windows桌面应用程序的最佳做法是什么?

为什么Console.Out.WriteLine存在?

双显示器应用程序如何解决这个焦点问题?

为什么我在尝试本地安装cs-script时出错?

在线程中调用列表框

为什么FileSystemInfo不声明GetAccessControl方法?

我如何移动粘贴/贴紧wpf窗口

获得一个好的调用升级命令有几个微妙之处。 这是我们在PowerShell社区扩展 (2.1 Beta)中使用的Invoke-Elevated的当前实现。 你可能会发现它有助于让你的工作,或者你可以抓住PSCX 2.1测试版。

Kubernetes powershell 模块的 Powershell cmdlet 参考

Kubernetes powershell 模块的 Powershell cmdlet 参考

如何解决Kubernetes powershell 模块的 Powershell cmdlet 参考?

在哪里可以看到 k8s 模块 here 的 cmdlet 参考?

谢谢

解决方法

这是为了更好的可见性而发布的社区 wiki 答案。

正如评论中已经提到的,您正在寻找的参考资料可以在 here(module page 左侧的 Project Site 链接)中找到。

Microsoft.SharePoint.PowerShellpipe理单元:不正确的Windows PowerShell版本3.0 当前控制台支持Window PowerShell 2.0版

Microsoft.SharePoint.PowerShellpipe理单元:不正确的Windows PowerShell版本3.0 当前控制台支持Window PowerShell 2.0版

我在我的机器上安装了SharePoint 2010,用于开发目的,而且我错误地升级到.Net 4.0和PowerShell 3.0。

解决这个问题,使用-version 2.0或-v 2 switch / arguement运行powershell并不完全正常。

所以,这个问题是如何在PowerShell中添加Microsoft.Sharepoint.PowerShellpipe理单元,在具有.Net 4.0框架的机器上?

尝试1:

Windows中的IP发现

在Windows中检测文件“copY”操作

HRESULT:0x80040154(REGDB_E_CLASSNOTREG))

对于Windows窗体,PostMessage等于自己的什么?

从C#中selectsql Server数据库中的特定logging

PS> Add-PSSnapin Microsoft.Sharepoint.Powershell The local farm is not accessible. Cmdlets with FeatureDependencyId are not registered. PS> Get-SPSite('http://myServerName/') Get-SPSite : Microsoft SharePoint is not supported with version 4.0.30319.18052 of the Microsoft .Net Runtime.

好的,所以我尝试2:

PS> powershell.exe -version 2.0 PS> Add-PSSnapin Microsoft.Sharepoint.Powershell Add-PSSnapin : Incorrect Windows PowerShell version 3.0. Windows PowerShell version 2.0 is supported in the current console. At line:1 char:13 + Add-PSSnapin <<<< Microsoft.Sharepoint.PowerShell + CategoryInfo : InvalidArgument: (Microsoft.Sharepoint.PowerShell:String) [Add-PSSnapin],PSArgumentException + FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand

我也尝试设置快捷方式的目标。 并卸载以q结尾的Windows更新

所以,这是我的错误,我无法find任何信息: 不正确的Windows PowerShell版本3.0。 当前控制台支持Windows PowerShell版本2.0。

有什么想法吗?

在哪里写日志的Windows应用程序

如何测量C#中的系统空闲时间,不包括看电影等?

如何在Windows窗体上显示必填字段

.NET EXE和DLL之间的堆栈/堆区别

采用Windows媒体基础的H.264编码

如果我打电话,它似乎为我工作

powershell.exe -version 2.0

从命令提示符而不是从Powershell调用它。

最近SharePoint 2010更新后,我可以添加PowerShell管理单元,而在版本2.0中运行PowerShell

MSSQL/WMI/PowerShell结合篇(四)PowerShell发送微信信息

MSSQL/WMI/PowerShell结合篇(四)PowerShell发送微信信息

本文介绍如何通过PowerShell发送微信信息


先申请企业微信(企业、政府、组织三种类型),通过PowerShell调用企业微信的API群发接口发送微信信息,API详细信息可参考企业微信开发者文档


以下为PowerShell调用企业微信API发送文本信息

----Script File: send_WeChat.ps1


param($param1,$param2,$param3)


##设置16-32位长度的密钥

function Set-Key {

param([string]$string)

$length = $string.length

$pad = 32-$length

if (($length -lt 16) -or ($length -gt 32)) {Throw "String must be between 16 and 32 characters"}

$encoding = New-Object System.Text.ASCIIEncoding

$bytes = $encoding.GetBytes($string + "0" * $pad)

return $bytes

}


##解密方法

function Get-EncryptedData {

param($key,$data)

$data | ConvertTo-securestring -key $key |

ForEach-Object {[Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::securestringToBSTR($_))}

}


##发送微信方法

function send_WeChat_To_DBA {

Param(

[String]$corpid,

[String]$pwd,

[String]$Content

)

$auth_string = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=$corpid&corpsecret=$pwd"

$auth_values = Invoke-RestMethod $auth_string

$token = $auth_values.access_token

$body="{

`"toparty`":`"receive group id`",

`"agentid`":`"your agent id`",

`"text`":{

`"content`":`"$content`"

},

`"msgtype`":`"text`"

}"

$CN=[System.Text.Encoding]::UTF8.GetBytes($body)

Invoke-RestMethod "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=$token" -ContentType "application/json" -Method Post -Body $CN

}


##解析帐号密码

$cidstr= Get-Content E:\Monitor\cidstr.txt;

$pwdstr = Get-Content E:\Monitor\keystr.txt;

$cidkey = Set-Key $cidstr;

$pwdkey = Set-Key $pwdstr;

$cidfromFile = Get-Content E:\Monitor\wxcid.txt;

$pwdfromFile = Get-Content E:\Monitor\wxpwd.txt;

$corpid = Get-EncryptedData -data $cidfromFile -key $cidkey;

$pwd = Get-EncryptedData -data $pwdfromFile -key $pwdkey;


$content=$param1+$param2+$param3


##调用发送方法

send_WeChat_To_DBA -corpid $corpid -pwd $pwd -Content $content



##send_WeChat.ps1调用方式

E:\Monitor\send_WeChat.ps1 $param1 $param2 $param3

Powershell – 使用Powershell对Azure AD应用程序执行“授予权限”操作

Powershell – 使用Powershell对Azure AD应用程序执行“授予权限”操作

我正在使用AzureAD模块创建一个Azure AD应用程序来调用Microsoft Graph API.我可以成功生成访问令牌.但是,当我尝试调用API时,我有一个错误“消息”:“无效的范围声明/角色.”.

当我在Azure门户中创建的应用程序中单击“授予权限”按钮并重试对API的调用时,调用正在运行.

我没有找到任何地方如何使用Powershell执行此“授予权限”操作.有没有办法做到这一点 ?

谢谢

达米安

解决方法

有一种简单的方法(作为管理员),它要求您为Powershell安装AzureAD和AzureRM模块,并且不受Microsoft支持.

我的博客的原始帖子/参考在这里:http://www.lieben.nu/liebensraum/2018/04/how-to-grant-oauth2-permissions-to-an-azure-ad-application-using-powershell-unattended-silently/

应该帮助您完成此任务的特定代码示例:

Function Grant-OAuth2PermissionsToApp{
Param(
    [Parameter(Mandatory=$true)]$Username,#global administrator username
    [Parameter(Mandatory=$true)]$Password,#global administrator password
    [Parameter(Mandatory=$true)]$azureAppId #application ID of the azure application you wish to admin-consent to
)

$secpasswd = ConvertTo-securestring $Password -AsPlainText -Force
$mycreds = New-Object System.Management.Automation.PSCredential ($Username,$secpasswd)
$res = login-azurermaccount -Credential $mycreds
$context = Get-AzureRmContext
$tenantId = $context.Tenant.Id
$refreshToken = @($context.TokenCache.ReadItems() | where {$_.tenantId -eq $tenantId -and $_.ExpiresOn -gt (Get-Date)})[0].RefreshToken
$body = "grant_type=refresh_token&refresh_token=$($refreshToken)&resource=74658136-14ec-4630-ad9b-26e160ff0fc6"
$apiToken = Invoke-RestMethod "https://login.windows.net/$tenantId/oauth2/token" -Method POST -Body $body -ContentType 'application/x-www-form-urlencoded'
$header = @{
'Authorization' = 'Bearer ' + $apiToken.access_token
'X-Requested-With'= 'XMLHttpRequest'
'x-ms-client-request-id'= [guid]::NewGuid()
'x-ms-correlation-id' = [guid]::NewGuid()}
$url = "https://main.iam.ad.ext.azure.com/api/RegisteredApplications/$azureAppId/Consent?onBehalfOfAll=true"
Invoke-RestMethod -Uri $url -Headers $header -Method POST -ErrorAction Stop
}

关于PowerShell 2.0 sudo的限制powershell最高权限的介绍已经告一段落,感谢您的耐心阅读,如果想了解更多关于Kubernetes powershell 模块的 Powershell cmdlet 参考、Microsoft.SharePoint.PowerShellpipe理单元:不正确的Windows PowerShell版本3.0 当前控制台支持Window PowerShell 2.0版、MSSQL/WMI/PowerShell结合篇(四)PowerShell发送微信信息、Powershell – 使用Powershell对Azure AD应用程序执行“授予权限”操作的相关信息,请在本站寻找。

本文标签: