有谁知道如何使用 Azure 资源管理器(Powershell 或 JSON)在 Azure Web 应用程序上设置以下诊断设置。
使用 .json 我只能找到这些设置
"requestTracingEnabled": true, /* Failed request tracing, aka 'freb' */
"httpLoggingEnabled": true, /* IIS logs (aka Web server logging) */
"logsDirectorySizeLimit": 40, /* 40 MB limit for IIS logs */
"detailedErrorLoggingEnabled": true, /* Detailed error messages */
Run Code Online (Sandbox Code Playgroud)
这会打开 Web 服务器日志记录到文件系统,而不是应用程序日志记录或 Blob 存储。
使用 Powershell,此命令似乎仅适用于 ASM,因为它找不到提供给它的非经典存储帐户
Enable-AzureWebsiteApplicationDiagnostic
Run Code Online (Sandbox Code Playgroud)
任何帮助,将不胜感激。我们目前使用的是 Azure Powershell 0.9.8
问候
我正在尝试从 UNC 路径名的根目录获取文件夹和文件。我正在使用Get-ChildItem.
我可以通过 UNC 路径从子文件夹中获取结果,但不能从根文件夹中获取结果。如果从命令行运行命令Get-ChildItem \\sf1\user1,则返回结果。
目录:\\sf1\user1 模式 LastWriteTime 长度 名称 ---- ------------- ------ ---- d---- 11/14/2013 3:40 PM 1.ISGROUP
当我尝试Get-ChildItem \\sf1从命令行执行时,出现错误。
Get-ChildItem:找不到路径“\\sf1”,因为它不存在。
在行:1 字符:1
+ Get-ChildItem \\sf1
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (\\sf1:String) [Get-ChildItem], ItemNotFoundException
+ FullQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
关于如何从 UNC 路径的根目录获取文件夹和文件的任何建议?
我正在使用 PowerShell 脚本安装计划任务,但我希望它在失败时重试 3 次,如何将其添加到我的计划任务注册脚本中?
$dropLocation = "C:\Tasks\"
$Action = New-ScheduledTaskAction -Execute "$dropLocation\Task.exe"
$Trigger = New-ScheduledTaskTrigger -Daily -At 10:15pm
$Settings = New-ScheduledTaskSettingsSet -RestartCount:3
Register-ScheduledTask -Action $Action -Trigger $Trigger -TaskName "$taskName" -Settings $Settings -Description "TaskDescription"
Run Code Online (Sandbox Code Playgroud) 我有两个问题,acually:
$arraylist = New-Object 'system.collections.arraylist'
$arraylist.Add(1);
$arraylist.Add(2);
$csv = ??
#($arraylist-join -',') returns error: Cannot convert value "," to type "System.Int32". Error: "Input string was not in a correct format."
Run Code Online (Sandbox Code Playgroud) 我正在尝试测试 PowerShell 中数组中所有项的条件是否为真(类似于 LINQ 的All函数)。除了编写手动 for 循环外,在 PowerShell 中执行此操作的“正确”方法是什么?
具体来说,这是我试图从 C# 翻译的代码:
public static IEnumerable<string> FilterNamespaces(IEnumerable<string> namespaces)
=> namespaces
.Where(ns => namespaces
.Where(n => n != ns)
.All(n => !Regex.IsMatch(n, $@"{Regex.Escape(ns)}[\.\n]")))
.Distinct();
Run Code Online (Sandbox Code Playgroud) 我在 Powershell 控制台中显示中文字符时遇到了一些问题。所有中文都显示为矩形。我相信这是一个编码问题。有谁知道如何配置 Powershell 控制台以使用 UTF8 编码?
我在 Visual Studio Team Services(是 Visual Studio Online)构建中设置了构建定义。
我没有在“工作文件夹”中设置任何内容,因为我假设它默认为信息中指定的脚本所在的文件夹。
当构建运行时,它会在 Powershell 步骤抛出异常。
不知何故,工作文件夹不是脚本所在的文件夹。有什么建议可以解决它吗?
我试图让一个不使用 invoke-webrequest 的脚本工作。我遇到的问题是,当我运行脚本时会出现弹出提示,弹出窗口包含以下消息;
“Windows 安全警告为了允许该网站为您提供个性化信息,您是否允许它在您的计算机上放置一个小文件(称为 cookie)?” 用户是没有响应我正在执行的代码如下:
$ParsedHTML = New-Object -com "HTMLFILE"
$webresponse = New-Object System.Net.WebClient
$webresponse.Headers.Add("Cookie", $CookieContainer.GetCookieHeader($url))
$result = $webresponse.DownloadString($url)
$ParsedHTML.IHTMLDocument2_write($webresponse)
$ParsedHTML.body.innerText
Run Code Online (Sandbox Code Playgroud)
这段代码的主要问题是我正在使用部分网络链接的 $url 检查是否启用了 cookie,并且这段代码导致返回值禁用。
我的问题是,有没有办法在不更改测试 url 站点的输出响应的情况下处理 cookie 请求。
注意:此脚本将在数百台远程计算机上自动化进程,因此未处理的弹出窗口只会阻止脚本运行。
我是 PowerShell 的完全新手,但一直在研究测试我设置的消息队列 (MSMQ) 的最佳方法。到目前为止,我已经能够在 Powershell 中运行以下命令来获取我的所有队列以查看存在的内容:
gwmi -class Win32_PerfRawData_MSMQ_MSMQQueue -computerName . |
ft -prop Name, MessagesInQueue
Run Code Online (Sandbox Code Playgroud)
这将返回我可用的 MSMQ 队列列表。我现在只想向返回的队列之一发布消息以测试连接。我的队列被命名为:
<server>\private$\<queuename>
Run Code Online (Sandbox Code Playgroud)
我曾尝试使用以下方法但没有运气:
$myqueue = '.\Private$\portalemailqueue'
$MyQueue.Send("<<Message>>", "test1")
Method invocation failed because [System.String] does not contain a method named 'Send'.
At line:3 char:1
+ $MyQueue.Send("<<Message>>", "test1")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound
Run Code Online (Sandbox Code Playgroud)
我一生都无法弄清楚如何做到这一点。有没有人有任何好的资源或代码来做到这一点?
如何使用 PowerShell v3 从雅虎 SMTP 服务器发送电子邮件?需要身份验证。
powershell ×10
azure ×1
azure-devops ×1
cookies ×1
directory ×1
json ×1
linq ×1
msmq ×1
smtp ×1
subdirectory ×1
tfs ×1
tfsbuild ×1
unc ×1