小编Ser*_*ver的帖子

如果文件夹是联结点,请在PowerShell代码中进行测试?

如果文件夹是联结点,我如何在PowerShell代码中进行测试?

powershell ntfs junction

5
推荐指数
3
解决办法
6802
查看次数

SharePoint 2010:从UI执行的功能接收器代码,而不是PowerShell或stdadm

我有一个包含Web范围功能的WSP,其代码如下:

using System;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Security;

namespace Macaw.DualLayout.Samples.Features.DualLayoutSampleEmpty_Web
{
    [Guid("8b558382-5566-43a4-85fa-ca86845b04b0")]
    public class DualLayoutSampleEmpty_WebEventReceiver : SPFeatureReceiver
    {
        public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            using (SPWeb web = (SPWeb)properties.Feature.Parent)
            {
                using (SPSite site = (SPSite)web.Site)
                {
                    Uri uri = new Uri(site.Url + "/_catalogs/masterpage/DLSampleEmpty.master");
                    web.CustomMasterUrl = uri.AbsolutePath; // Master for all publishing pages
                    web.Update();
                }
            }
        }

        public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
        {
            using (SPWeb web = (SPWeb)properties.Feature.Parent)
            {
                using (SPSite site = (SPSite)web.Site)
                {
                    Uri uri = …
Run Code Online (Sandbox Code Playgroud)

sharepoint sharepoint-2010

5
推荐指数
2
解决办法
7381
查看次数

如何为SharePoint Designer 2010编写加载项

我正在寻找的信息,如果你到文件 - >选项有可能添加COM加载项的书面SharePoint设计2010的加载项,我想自己写一个,最好是用C#.

任何指向文档/示例的指针?可以访问哪些SharePoint特定类?

sharepoint

5
推荐指数
0
解决办法
668
查看次数

在PowerShell中使用分隔符连接部件的最佳方法

我需要将多个Url元素连接成一个字符串,因此我编写了通用的Join-Parts函数:

filter Skip-Null { $_|?{ $_ } }

function Join-Parts
{
    param
    (
        $Parts = $null,
        $Separator = ''
    )

    [String]$s = ''
    $Parts | Skip-Null | ForEach-Object {
        $v = $_.ToString()
        if ($s -ne '')
        {
            if (-not ($s.EndsWith($Separator)))
            {
                if (-not ($v.StartsWith($Separator)))
                {
                    $s += $Separator
                }
                $s += $v
            }
            elseif ($v.StartsWith($Separator))
            {
                $s += $v.SubString($Separator.Length)
            }
        }
        else
        {
            $s = $v
        }
    }
    $s
}

Join-Parts -Separator '/' -Parts 'http://mysite','sub/subsub','/one/two/three'
Join-Parts -Separator '/' -Parts 'http://mysite',$null,'one/two/three' …
Run Code Online (Sandbox Code Playgroud)

powershell powershell-2.0

5
推荐指数
4
解决办法
9048
查看次数

PowerShell Invoke-SqlCmd和内存使用情况

如果我执行以下Powershell命令:

Invoke-Sqlcmd `
  -ServerInstance '(local)' -Database 'TestDatabase' `
  -Query "select top 1000000 * from dbo.SAMPLE_CUSTOMER" | Out-Null
Run Code Online (Sandbox Code Playgroud)

我看到我的内存使用量不断增加。它使用1GB的内存。

如果再次启动该命令,则内存增加到1.8GB,然后减少到800MB(垃圾回收?),然后再次开始增长。

我尝试按照http://blogs.technet.com/b/heyscriptingguy/archive/2013/07/30/learn-how-to-configure文章中的步骤将PowerShell Shell和插件的内存占用减少到100MB -powershell-memory.aspx,但是我仍然看到内存增加远远超过已配置的100MB。

我有一些问题:

  1. 为什么PowerShell不遵守设置MaxMemoryPerShellMB给出的内存限制?
  2. 为什么要Invoke-Sqlcmd吃掉内存,而不是“忘记”管道中处理的记录
  3. 为什么在完成处理后,PowerShell进程不自动回收内存?
  4. 如何在不占用大量内存的情况下处理许多SQL记录?

sql-server powershell

5
推荐指数
0
解决办法
889
查看次数

在运行空间中从c#调用PowerShell脚本,并获取发生错误的行号

我在C#中有一些PowerShell主机,我从中执行PowerShell脚本代码.下面的代码来自Visual Studio的Add0In中的主机.问题是,如果PowerShell脚本代码中发生错误,我不知道发生错误的PowerShell脚本文件的文件和行号.

我的托管代码如下:

        public Exception Execute(string scriptcode, Hashtable variables)
    {
        Runspace runspace = null;
        Pipeline pipeline = null;
        PipelineStateInfo info = null;

        try
        {
            // Make our output window active
            Logger.ShowOutputWindow();

            // Create the runspace and stuff.
            runspace = RunspaceFactory.CreateRunspace(host);
            pipeline = runspace.CreatePipeline();

            runspace.Open();

            // Add our scriptcode to the pipeline
            pipeline.Commands.Add(new Command(scriptcode, true));

            // We don't want to get PSObjects out of the pipeline, output result as string in default way
            pipeline.Commands.Add(new Command("Out-Default", true));

            // Set up global variables …
Run Code Online (Sandbox Code Playgroud)

c# powershell

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

在保持纵横比的区域内拟合 N 个矩形

我有 N 个矩形,所有的尺寸都相同rectWidth * rectHeight。我有一个尺寸为areaWidth * areaHeight的区域。我想在保持矩形纵横比的区域内放置 N 个矩形,调整矩形的大小以使其适合。矩形之间我想要的间隔空间

矩形的尺寸应该是多少才能将它们全部放在矩形内并保持纵横比?

algorithm math rectangles

4
推荐指数
2
解决办法
1075
查看次数

我可以在 HTML 页面上有多个 Svelte 组件吗?

是否可以拥有一个纯 HTML 页面并在多个位置注入 Svelte 组件,例如React Portals?所以我不想将 Svelte 用作单页应用程序 (SPA),而是在现有 HTML 页面上使用 Svelte 组件。是否可以让单独的 Svelte 组件使用事件调度器相互通信,并使用Context APISvelte 存储共享状态?

我无法控制呈现的 HTML,它来自 CMS。所以像https://github.com/sveltejs/svelte/issues/1849这样的东西将不起作用......我无法使用 Svelte 编译器“编译”HTML 页面。

svelte

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

问:为 Azure 静态 Web 应用配置 CORS(预览)

我将图像、CSS 和 JavaScript 捆绑包等工件部署到Azure 静态 Web 应用程序(预览版)。如果我使用来自其他站点的 JavaScript 包,则会收到 CORS 错误。在静态 Web 应用程序(预览版)的 Azure 配置中,没有配置 CORS 的选项。关于如何配置 CORS 有什么想法吗?

azure-storage cors azure-web-app-service

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

从自定义运行空间中执行的PowerShell启动应用程序,让应用程序保持运行,完成脚本?

我有一个自定义PowerShell运行空间,我从中执行脚本(简化):

Pipeline pipeline = myRunSpace.CreatePipeline(@"c:\temp\Myscript.ps1");
Collection<PSObject> results = pipeLine.Invoke();
Run Code Online (Sandbox Code Playgroud)

在脚本中我做:

# c:\temp\MyScript.ps1
notepad.exe
Run Code Online (Sandbox Code Playgroud)

现在Invoke()关闭记事本时的回报.

有没有办法启动应用程序,保持应用程序运行,但完成脚本代码?

powershell

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