Backup-WDServer: How to specify encryption password - iis

I read about the Web Deploy Powershell Cmdlets, and I'd like to start using them. Of course, the first task as I begin is to backup the current configuration state of my test webserver--and this cmdlet should do it:
Backup-WDServer -ConfigOnly
But, when I run it I get this complaint--I'm unsure how to resolve it:
Backup-WDServer : The property 'password' located at '/webServer/appHostConfig[#path='']/location[#path='']/section[#name='system.applicationHost/applicationPools']/applicationPools/applicationPoolDefaults/processModel' is
marked as secure. You must specify an encryption password to archive this property.
At line:1 char:1
+ Backup-WDServer -ConfigOnly
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Backup-WDServer], DeploymentEncryptionException
+ FullyQualifiedErrorId : Microsoft.Web.Deployment.PowerShell.BackupServer

I had trouble finding documentation, but after spending time with IL DASM, reading more in the link provided in the question, and experimenting, I found this works:
Backup-WDServer -SourceSettings #{encryptPassword='password'} -ConfigOnly
If anyone has a link to more complete documentation I'd appreciate it--but Bing and Google didn't find much.

It is an old thread however there is the answer:
Restore-WDServer -DestinationSettings #{encryptPassword='password'} -Package /path/to/the/zip/file

How do you set encryptpassword for the Restore-WDServer? if you did this to backup
Backup-WDServer -SourceSettings #{encryptPassword='password'} -ConfigOnly

Related

How do I mention a role with Discord.js?

I am making a bot and I am trying to Ping a certain role. Here is the relevant code:
let msga = msg.author;
msg.channel.send("#NES Found one!! " + msga);
#NES is the role I am trying to ping/mention.
The currently accepted answer is incorrect. You ping a user with <#id>, not a role.
As stated in this Github issue, for roles, you have to use <#&id> and the role has to be pingable.
So, the correct code for the question would be something like:
msg.channel.send("<#&" + roleId + "> Found one!! " + msga);
Or, using fancy formatted strings:
msg.channel.send(`<#&${roleId}> Found one!! ${msga}`);
Just add an opening and closing angle bracket and use the role id to make the mention.
msg.channel.send("<#id> Found one!! " + msga);
This answer was valid for older versions of discord.js (I believe v11 and under) but is now invalid for v12+ use yummypasta's solution for the newer versions.
It is:
message.channel.send(`<#& id >`);
try this:
msg.channel.send(`<#&${'roleId'}> Found one!! ${msga}`);

Adding Azure Information Protection Label to Powershell script using Outlook 2016

I'm trying to add a custom header for AIP's msip_labels to a Powershell script that I'm writing. I've figured out how to do this with .Net.SMTP using:
$message.Headers.Add("msip_labels","MSIP_Label_aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee_Enabled=True; MSIP_Label_aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee_SiteId=00000000-1111-2222-3333-444444444444; MSIP_Label_aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee_Owner=user2#domain.tld; MSIP_Label_aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee_SetDate=$((Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ")); MSIP_Label_aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee_Name=Internal; MSIP_Label_aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee_Application Microsoft Azure Information Protection; MSIP_Label_aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee_ActionId ffffffff-5555-6666-7777-888888888888; MSIP_Label_aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee_Extended_MSFT_Method Manual")
Based on research I've done this should work using Outlook 2016 in theory:
$Outlook = New-Object -ComObject Outlook.Application
$message = $Outlook.CreateItem(0)
$message.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/string/{00020386-0000-0000-C000-000000000046}/msip_labels", "MSIP_Label_aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee_Enabled=True; MSIP_Label_aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee_SiteId=00000000-1111-2222-3333-444444444444; MSIP_Label_aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee_Owner=user2#domain.tld; MSIP_Label_aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee_SetDate=$((Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ")); MSIP_Label_aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee_Name=Internal; MSIP_Label_aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee_Application=Microsoft Azure Information Protection; MSIP_Label_aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee_ActionId=ffffffff-5555-6666-7777-888888888888; MSIP_Label_aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee_Extended_MSFT_Method=Manual")
$message.To = "user1#domain.tld"
$message.Cc = "user3#domain.tld"
$message.Subject = "Report"
$message.HTMLBody = #"
<p><font face = "Calibri" size = "3">Hello World</p></font>
"#
$reportMessage.Send()
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($Outlook) | Out-Null
I confirmed this using a MAPI viewer that this is what's used in Outlook itself with other emails I've sent using just Outlook. But, when I tried running this in my script I get this error:
Exception setting "SetProperty": Cannot convert the "MSIP_Label_aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee_Enabled=True; MSIP_Label_aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee_SiteId=00000000-1111-2222-3333-444444444444;
MSIP_Label_aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee_Owner=user2#domain.tld; MSIP_Label_aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee_SetDate=$((Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ")); MSIP_Label_aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee_Name=Internal;
MSIP_Label_aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee_Application=Microsoft Azure Information Protection; MSIP_Label_aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee_ActionId=ffffffff-5555-6666-7777-888888888888;
MSIP_Label_aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee_Extended_MSFT_Method=Manual" value of type "string" to type "Object".
At C:\emailtest.ps1:21 char:1
+ $message.PropertyAccessor.SetProperty("http://schemas.microsoft ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodException
+ FullyQualifiedErrorId : RuntimeException
Which doesn't seem to make much sense it's suppose to be a string in the MAPI schema, so I'm not sure why it thinks it should be an object. I even tried converting those values to objects using ConvertFrom-String, but it didn't work. Any advice on this would be greatly appreciated.
Try to reduce the string length you pass as a value. Does it work correctly?
It seems you need to use a low-level API on which Outlook is based on - Extended MAPI. It doesn't have any restrictions on the string length unlike OOM if you use the OpenProperty method. Also, you may consider using any third-party wrapper around that API such as Redemption.
If you use PropertyAccessor, you must have good knowledge of exception handling logic. Below I list some roadblocks that you may run into:
The body and content of an attachment of an Outlook items are not accessible through PropertyAccessor.
The PropertyAccessor ignores any seconds of the date/time value
String properties are limited in size depending on the information store type.
Limitation: Personal Folders files (.pst) and Exchange offline folders files (.ost) cannot be more than 4,088 bytes.
Limitation: For direct online access to Exchange mailbox or Public Folders hierarchy, the limit is 16,372 bytes.
Binary properties only those whose values are under 4,088 byte can be retrieved or set. (If trying to use larger values, you get an out-of-memory error).
You may find the Don't stumble over a stone working with the PropertyAccessor and StorageItem classes in Outlook 2007 article helpful.
It worked for me by appending a null character at the end of the string ( "`0" ) This is required by type "PtypString", required by property.
https://learn.microsoft.com/en-us/openspecs/exchange_server_protocols/ms-oxcdata/0c77892e-288e-435a-9c49-be1c20c7afdb

SQL Azure Schema Issue

I'm getting an email regarding a Schema Issue on my SQL Azure Database and it reads something like this:
"Invalid column name 'False'" Error code : 207
However it doesn't appear to have any more information and I wouldn't even know where to start because the schema was created before I started in the project, but I suspect this is coming from a Stored Procedure or View.
This is all being reported in Azure Portal, but I have no idea how to proceed. Is there any other way to get the suggestions on Azure Portal in SSMS? I already tried Tuning Advisor and I got an error that SQL Azure was not supported.
I use this query to to search objects in this scenario. This will find every occurrence of false and should help you find the offending column. This will find every occurrence of whatever you define #searchName as.
I found this on Pinal Dave's blog, way back. This works in Azure SQL.
declare #searchName varchar(50) = 'false'
select #searchName as SearchName,
OBJECT_SCHEMA_NAME(OBJECT_ID) + '.' + OBJECT_NAME(OBJECT_ID) as ObjectName,
[definition]
from sys.sql_modules
where definition LIKE '%' + #searchName + '%'
order by OBJECT_SCHEMA_NAME(OBJECT_ID) + '.' + OBJECT_NAME(OBJECT_ID)

Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding

I am using Window PowerShell to import XRM Solution in MS crm 2011.
And using the following cmdlets
PS> Import-Module “C:\Program Files (x86)\Xrm CI Framework\CRM 2011\PowerShell Cmdlets\Xrm.Framework.CI.PowerShell.dll”
PS> Import-XrmSolution -ConnectionString $ConUrl -SolutionFilePath $path -OverwriteUnmanagedCustomizations $true
Then the PowerShell throws a Exception:
Import-XrmSolution : The request channel timed out while waiting for a reply after 00:01:59.8729770. Increase the timeout value passed to the call to Request or increase the
SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.
At C:\Users\rkhalid\Desktop\PowerShell Scripts\Automated.ps1:35 char:5
+ Import-XrmSolution -ConnectionString $ConUrl -SolutionFilePath $path -Overwr ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Import-XrmSolution], TimeoutException
+ FullyQualifiedErrorId : System.TimeoutException,Xrm.Framework.CI.PowerShell.ImportXrmSolutionCommand
Should I increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding?
I am not sure but I think increase the SendTimeout value on the Binding but I don't know how to do that?
I experienced the same issue, and I increased the timeout value in the target server connection string. The default is 2 (minutes). Try setting it to 5 or so and then wrapping the Import-XrmSolution call in Measure-Command{ Import-XrmSolution } to see how long it takes (if you are curious).
$targetCrmConnectionUrl = "ServiceUri=http://your-server/your-organization/XRMServices/2011/Organization.svc; Domain=your-domain; Username=your-username; Password=your-password; Timeout=5"

Site Column Page Not Accessible

I accidentally created a field type called "Test" instead of Text using the following
Powershell command:
Get site and web object
$site = Get-SPSite -Identity "http://mysite/sites/.."
$web = $site.RootWeb
#Assign fieldXML variable with XML string for site column
$fieldXML = '<Field Type="Test"...etc.
Poweshell threw the following error:
Exception calling "AddFieldAsXml" with
"1" argument(s): "Field type Test is
not installed properly. Go to the
list settings page to delete this
field. " At
C:\Scripts\addsitecolumn.ps1:25
char:26
+ $web.Fields.AddFieldAsXml <<<< ($fieldXML)
+ CategoryInfo : NotSpecified: (:) [],
MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
Is there a Powershell command to delete the Test Field or is there a way to get to this fields 'hidded' page?
I ran into a similar problem today. I ran Sharepoint Manager 2010 and got the SchemaXML off from the site collection and found out that there were 3 site columns with nothing defined in it. I tried to remove it by powershell above with display name (which is "") or index, but none of that work as the item object see it as null. Then I came across this post:
https://sharepoint.stackexchange.com/questions/11945/error-message-field-type-publishing-image-is-not-installed-properly-go-to-the
Which remove it from the content database and that worked for me. Right after that I check the SchemaXML and the 3 strange site columns were removed. It's interesting how the content type table ties directly into this problem.
Try this in PowerShell:
$web1 = Get-SPWeb "http://testWeb"
$field = $web1.Fields["Test 1"]
$field.Delete()
"Test 1" is the Display name of the field you tried to add earlier.

Resources