我是PowerShell的新手,我正尝试将Powershell的输出插入到我的SQL表中...
这是我的SQL表
var sessionid = Driver.SessionId.ToString();
string reqString = "{\"status\":\"failed\", \"reason\":\"Incorrect Text Found\"}";
byte[] requestData = Encoding.UTF8.GetBytes(reqString);
Uri myUri = new Uri(string.Format($"https://api-cloud.browserstack.com/app-automate/sessions/{sessionid}.json"));
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
WebRequest myWebRequest = HttpWebRequest.Create(myUri);
HttpWebRequest myHttpWebRequest = (HttpWebRequest)myWebRequest;
myWebRequest.ContentType = "application/json";
myWebRequest.Method = "PUT";
myWebRequest.ContentLength = requestData.Length;
using (Stream st = myWebRequest.GetRequestStream()) st.Write(requestData, 0, requestData.Length);
NetworkCredential myNetworkCredential = new NetworkCredential("<username>", "<AccessKey>");
CredentialCache myCredentialCache = new CredentialCache();
myCredentialCache.Add(myUri, "Basic", myNetworkCredential);
myHttpWebRequest.PreAuthenticate = true;
myHttpWebRequest.Credentials = myCredentialCache;
myWebRequest.GetResponse().Close();
Powershell cmd
CREATE TABLE [dbo].[u_servicePreferences2](
[id] [INT] IDENTITY(1,1) NOT FOR REPLICATION NOT NULL,
[ProductVersion] [VARCHAR](1000) NOT NULL,
[FileVersion] [VARCHAR](2000) NULL,
[Filename] VARCHAR(MAX)
CONSTRAINT [PK_u_servicePreferences2] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 80) ON [PRIMARY],
CONSTRAINT [IX_u_servicePreferences2] UNIQUE NONCLUSTERED
(
[Filename] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 80) ON [PRIMARY]
) ON [PRIMARY]
输出此内容...
(get-item -Path 'E:\Services\Services.EmailOutbound\Services.EmailOutbound.exe').VersionInfo
我具有脚本的初始结构,但是不知道如何在脚本中执行powershell来将记录创建到数据库中
ProductVersion FileVersion FileName
-------------- ----------- --------
7.1.6750.30654 7.1.6750.30654 E:\Services\Services.EmailOutbound\Services.EmailOutbound.exe
我们将为您提供帮助